#include <core/Logger.hpp> #include <cstdio> #include "../Tests.hpp" #include "core/Image.hpp" static void testReadPNG8( const char* path, const char* name, int width, int height, int channels) { char fullPath[512]; Core::formatBuffer(fullPath, sizeof(fullPath), "#/#.png", path, name); Core::Image8 i; TEST(width == 0, i.read(fullPath)); if(width != 0) { TEST_TRUE(i.data.getLength() > 0); } TEST(width, i.width); TEST(height, i.height); TEST(channels, i.channels); } static void testReadPNG16( const char* path, const char* name, int width, int height, int channels) { char fullPath[512]; Core::formatBuffer(fullPath, sizeof(fullPath), "#/#.png", path, name); Core::Image16 i; TEST(width == 0, i.read(fullPath)); if(width != 0) { TEST_TRUE(i.data.getLength() > 0); } TEST(width, i.width); TEST(height, i.height); TEST(channels, i.channels); } 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); useReport = false; testReadPNG8(path, "nope", 0, 0, 0); useReport = true; 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); useReport = false; testReadPNG16(path, "nope", 0, 0, 0); useReport = true; }