Use std::string to increase portability

This commit is contained in:
Pavel Krajcevski 2014-11-06 16:21:12 -05:00
parent c83e00db1c
commit 5dc66f7469

View file

@ -58,29 +58,31 @@
#include "ImageFile.h" #include "ImageFile.h"
#include "Image.h" #include "Image.h"
#include <string>
class ImageTester { class ImageTester {
private: private:
static void GenerateTestFilenames(const char *suffix, char *outASTC, char *outPNG) { static std::string GenerateTestFilename(const std::string &basename,
const char *basename = "mandrill"; const std::string &suffix,
sprintf(outASTC, "%s_%s.astc", basename, suffix); const std::string &ext) {
sprintf(outPNG, "%s_decompressed_%s.png", basename, suffix); return basename + suffix + std::string(".") + ext;
} }
public: public:
explicit ImageTester(const char *suffix) { explicit ImageTester(const char *suffix) {
char astcFilename[256]; std::string astcFilename =
char pngFilename[256]; GenerateTestFilename("mandrill_", std::string(suffix), "astc");
std::string pngFilename =
GenerateTestFilename("mandrill_decompressed_", std::string(suffix), "png");
GenerateTestFilenames(suffix, astcFilename, pngFilename); ImageFile astc (astcFilename.c_str());
ImageFile astc (astcFilename);
bool success = astc.Load(); bool success = astc.Load();
EXPECT_TRUE(success); EXPECT_TRUE(success);
if (!success) { if (!success) {
return; return;
} }
ImageFile png (pngFilename); ImageFile png (pngFilename.c_str());
success = png.Load(); success = png.Load();
EXPECT_TRUE(success); EXPECT_TRUE(success);
if (!success) { if (!success) {
@ -92,7 +94,6 @@ class ImageTester {
} }
}; };
// 4x4 12x12 8x8 6x5 10x8
TEST(Decompressor, Decompress4x4) { TEST(Decompressor, Decompress4x4) {
ImageTester("4x4"); ImageTester("4x4");
} }