#include #include #include "../Tests.h" #include "core/Image.h" static void testReadPNG8(const char* path, const char* name, int width, int height, int channels) { char fullPath[512]; snprintf(fullPath, sizeof(fullPath), "%s/%s.png", path, name); Image8 image; TEST_BOOL(width == 0, initImage8(&image, fullPath)); if(width != 0) { TEST_NOT_NULL(image.data); } TEST_INT(width, image.width); TEST_INT(height, image.height); TEST_INT(channels, image.channels); destroyImage8(&image); } static void testReadPNG16(const char* path, const char* name, int width, int height, int channels) { char fullPath[512]; snprintf(fullPath, sizeof(fullPath), "%s/%s.png", path, name); Image16 image; TEST_BOOL(width == 0, initImage16(&image, fullPath)); if(width != 0) { TEST_NOT_NULL(image.data); } TEST_INT(width, image.width); TEST_INT(height, image.height); TEST_INT(channels, image.channels); destroyImage16(&image); } void testImageReader(const char* path) { testReadPNG8(path, "rgb8", 32, 64, 3); testReadPNG8(path, "rgb16", 32, 64, 3); testReadPNG8(path, "rgba8", 32, 64, 4); testReadPNG8(path, "rgba16", 32, 64, 4); testReadPNG8(path, "gray8", 32, 64, 1); testReadPNG8(path, "gray16", 32, 64, 1); testReadPNG8(path, "graya8", 32, 64, 2); testReadPNG8(path, "graya16", 32, 64, 2); logLevel = LOG_NONE; testReadPNG8(path, "nope", 0, 0, 0); logLevel = LOG_DEBUG; testReadPNG16(path, "rgb8", 32, 64, 3); testReadPNG16(path, "rgb16", 32, 64, 3); testReadPNG16(path, "rgba8", 32, 64, 4); testReadPNG16(path, "rgba16", 32, 64, 4); testReadPNG16(path, "gray8", 32, 64, 1); testReadPNG16(path, "gray16", 32, 64, 1); testReadPNG16(path, "graya8", 32, 64, 2); testReadPNG16(path, "graya16", 32, 64, 2); logLevel = LOG_NONE; testReadPNG16(path, "nope", 0, 0, 0); logLevel = LOG_DEBUG; }