123456789101112131415161718192021222324252627282930313233343536 |
- #include "tests/ImageReaderTests.h"
- #include "io/ImageReader.h"
- #include "tests/Test.h"
- #include "utils/StringBuffer.h"
- typedef StringBuffer<200> String;
- static void testReadPNG(Test& test, const char* path, const char* name,
- unsigned int channels, unsigned int bitdepth) {
- ImageReader::Image image;
- Error error =
- ImageReader::load(image, String(path).append(name).append(".png"));
- if(error.has()) {
- test.checkEqual(false, true,
- String("read ").append(name).append(" error"));
- return;
- }
- test.checkEqual(32u, image.width, String(name).append(" width"));
- test.checkEqual(64u, image.height, String(name).append(" height"));
- test.checkEqual(channels, image.channels, String(name).append(" channels"));
- test.checkEqual(bitdepth, image.bitdepth, String(name).append(" bitdepth"));
- test.checkEqual(true, image.data != nullptr, String(name).append(" data"));
- }
- void ImageReaderTests::test(const char* path) {
- Test test("ImageReader");
- testReadPNG(test, path, "rgb8", 3, 8);
- testReadPNG(test, path, "rgb16", 3, 16);
- testReadPNG(test, path, "rgba8", 4, 8);
- testReadPNG(test, path, "rgba16", 4, 16);
- testReadPNG(test, path, "gray8", 1, 8);
- testReadPNG(test, path, "gray16", 1, 16);
- testReadPNG(test, path, "graya8", 2, 8);
- testReadPNG(test, path, "graya16", 2, 16);
- test.finalize();
- }
|