Add some more hacky includes to be able to output debug images from our tests.

This commit is contained in:
Pavel Krajcevski 2013-09-06 02:02:02 -04:00
parent 91c79cd717
commit 3806efe6fc
2 changed files with 18 additions and 0 deletions

View file

@ -88,6 +88,7 @@ IF(PVRTEXLIB_FOUND)
# Make sure to include the PVR library headers... # Make sure to include the PVR library headers...
INCLUDE_DIRECTORIES( ${PVRTEXLIB_INCLUDE_DIRS} ) INCLUDE_DIRECTORIES( ${PVRTEXLIB_INCLUDE_DIRS} )
INCLUDE_DIRECTORIES( ${FasTC_SOURCE_DIR}/Core/include )
# The cpp file to compile for the test # The cpp file to compile for the test
ADD_EXECUTABLE(${TEST_NAME} DecompTestPVR.cpp) ADD_EXECUTABLE(${TEST_NAME} DecompTestPVR.cpp)
@ -96,6 +97,8 @@ IF(PVRTEXLIB_FOUND)
TARGET_LINK_LIBRARIES(${TEST_NAME} PVRTCEncoder) TARGET_LINK_LIBRARIES(${TEST_NAME} PVRTCEncoder)
TARGET_LINK_LIBRARIES(${TEST_NAME} gtest_main) TARGET_LINK_LIBRARIES(${TEST_NAME} gtest_main)
TARGET_LINK_LIBRARIES(${TEST_NAME} ${PVRTEXLIB_LIBRARIES} ) TARGET_LINK_LIBRARIES(${TEST_NAME} ${PVRTEXLIB_LIBRARIES} )
TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCIO)
TARGET_LINK_LIBRARIES(${TEST_NAME} FasTCCore)
ADD_TEST(${TEST_NAME} ADD_TEST(${TEST_NAME}
${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR} ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}

View file

@ -60,6 +60,13 @@
#include "TestUtils.h" #include "TestUtils.h"
// #define OUTPUT_DEBUG_IMAGE
#ifdef OUTPUT_DEBUG_IMAGE
# include "Core/include/Image.h"
# include "IO/include/ImageFile.h"
#endif // OUTPUT_DEBUG_IMAGE
class ImageTester { class ImageTester {
public: public:
ImageTester(const char *filename) { ImageTester(const char *filename) {
@ -89,6 +96,13 @@ public:
EXPECT_EQ(PixelPrinter(libPixels[i]), PixelPrinter(outPixels[i])); EXPECT_EQ(PixelPrinter(libPixels[i]), PixelPrinter(outPixels[i]));
} }
#ifdef OUTPUT_DEBUG_IMAGE
char dbgfname[256];
sprintf(dbgfname, "Debug%s.png", filename);
::ImageFile imgFile(dbgfname, eFileFormat_PNG, ::Image(w, h, outPixels));
imgFile.Write();
#endif // OUTPUT_DEBUG_IMAGE
delete outPixels; delete outPixels;
} }
}; };
@ -104,3 +118,4 @@ TEST(Decompressor, DecompressWhite) {
TEST(Decompressor, DecompressGray) { TEST(Decompressor, DecompressGray) {
ImageTester("gray.pvr"); ImageTester("gray.pvr");
} }