|
@@ -4,16 +4,6 @@
|
|
|
#include "utils/List.h"
|
|
|
#include "utils/StringBuffer.h"
|
|
|
|
|
|
-static void testRead(Test& test, PNGReader& png, const char* text) {
|
|
|
- List<ColorChannel> buffer;
|
|
|
- buffer.resize(png.getBufferSize());
|
|
|
- test.checkEqual(true, png.getBufferSize() > 0, text);
|
|
|
- test.checkEqual(png.getBufferSize(), buffer.getLength(), text);
|
|
|
- if(png.getBufferSize() == buffer.getLength()) {
|
|
|
- test.checkEqual(false, png.readData(buffer.begin()).has(), text);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
static void testReadRGB8(Test& test, const char* path) {
|
|
|
PNGReader png;
|
|
|
if(png.load(StringBuffer<200>(path).append("rgb8.png")).has()) {
|
|
@@ -23,20 +13,14 @@ static void testReadRGB8(Test& test, const char* path) {
|
|
|
test.checkEqual(32, png.getWidth(), "rgb8 width");
|
|
|
test.checkEqual(64, png.getHeight(), "rgb8 height");
|
|
|
test.checkEqual(3, png.getChannels(), "rgb8 channels");
|
|
|
- testRead(test, png, "rgb8 read");
|
|
|
+ test.checkEqual(true, png.getData() != nullptr, "rgb8 data");
|
|
|
}
|
|
|
|
|
|
static void testReadRGB16(Test& test, const char* path) {
|
|
|
PNGReader png;
|
|
|
- if(png.load((StringBuffer<200>(path).append("rgb16.png"))).has()) {
|
|
|
- test.checkEqual(false, true, "read rgb16 error");
|
|
|
- return;
|
|
|
- }
|
|
|
- test.checkEqual(32, png.getWidth(), "rgb16 width");
|
|
|
- test.checkEqual(64, png.getHeight(), "rgb16 height");
|
|
|
- test.checkEqual(3, png.getChannels(), "rgb16 channels");
|
|
|
- test.checkEqual(32 * 64 * 3, png.getBufferSize(), "rgb16 channels");
|
|
|
- testRead(test, png, "rgb16 read");
|
|
|
+ test.checkEqual(
|
|
|
+ true, png.load((StringBuffer<200>(path).append("rgb16.png"))).has(),
|
|
|
+ "read rgb16 error");
|
|
|
}
|
|
|
|
|
|
static void testReadRGBA8(Test& test, const char* path) {
|
|
@@ -48,21 +32,14 @@ static void testReadRGBA8(Test& test, const char* path) {
|
|
|
test.checkEqual(32, png.getWidth(), "rgba8 width");
|
|
|
test.checkEqual(64, png.getHeight(), "rgba8 height");
|
|
|
test.checkEqual(4, png.getChannels(), "rgba8 channels");
|
|
|
- test.checkEqual(32 * 64 * 4, png.getBufferSize(), "rgba8 channels");
|
|
|
- testRead(test, png, "rgba8 read");
|
|
|
+ test.checkEqual(true, png.getData() != nullptr, "rgba8 data");
|
|
|
}
|
|
|
|
|
|
static void testReadRGBA16(Test& test, const char* path) {
|
|
|
PNGReader png;
|
|
|
- if(png.load(StringBuffer<200>(path).append("rgba16.png")).has()) {
|
|
|
- test.checkEqual(false, true, "read rgba16 error");
|
|
|
- return;
|
|
|
- }
|
|
|
- test.checkEqual(32, png.getWidth(), "rgba16 width");
|
|
|
- test.checkEqual(64, png.getHeight(), "rgba16 height");
|
|
|
- test.checkEqual(4, png.getChannels(), "rgba16 channels");
|
|
|
- test.checkEqual(32 * 64 * 4, png.getBufferSize(), "rgba16 channels");
|
|
|
- testRead(test, png, "rgba16 read");
|
|
|
+ test.checkEqual(
|
|
|
+ true, png.load(StringBuffer<200>(path).append("rgba16.png")).has(),
|
|
|
+ "read rgba16 error");
|
|
|
}
|
|
|
|
|
|
static void testReadGray8(Test& test, const char* path) {
|
|
@@ -74,21 +51,14 @@ static void testReadGray8(Test& test, const char* path) {
|
|
|
test.checkEqual(32, png.getWidth(), "gray8 width");
|
|
|
test.checkEqual(64, png.getHeight(), "gray8 height");
|
|
|
test.checkEqual(1, png.getChannels(), "gray8 channels");
|
|
|
- test.checkEqual(32 * 64, png.getBufferSize(), "gray8 channels");
|
|
|
- testRead(test, png, "gray8 read");
|
|
|
+ test.checkEqual(true, png.getData() != nullptr, "gray8 data");
|
|
|
}
|
|
|
|
|
|
static void testReadGray16(Test& test, const char* path) {
|
|
|
PNGReader png;
|
|
|
- if(png.load(StringBuffer<200>(path).append("gray16.png")).has()) {
|
|
|
- test.checkEqual(false, true, "read gray16 error");
|
|
|
- return;
|
|
|
- }
|
|
|
- test.checkEqual(32, png.getWidth(), "gray16 width");
|
|
|
- test.checkEqual(64, png.getHeight(), "gray16 height");
|
|
|
- test.checkEqual(1, png.getChannels(), "gray16 channels");
|
|
|
- test.checkEqual(32 * 64, png.getBufferSize(), "gray16 channels");
|
|
|
- testRead(test, png, "gray16 read");
|
|
|
+ test.checkEqual(
|
|
|
+ true, png.load(StringBuffer<200>(path).append("gray16.png")).has(),
|
|
|
+ "read gray16 error");
|
|
|
}
|
|
|
|
|
|
static void testReadGrayA8(Test& test, const char* path) {
|
|
@@ -100,21 +70,14 @@ static void testReadGrayA8(Test& test, const char* path) {
|
|
|
test.checkEqual(32, png.getWidth(), "graya8 width");
|
|
|
test.checkEqual(64, png.getHeight(), "graya8 height");
|
|
|
test.checkEqual(2, png.getChannels(), "graya8 channels");
|
|
|
- test.checkEqual(32 * 64 * 2, png.getBufferSize(), "graya8 channels");
|
|
|
- testRead(test, png, "graya8 read");
|
|
|
+ test.checkEqual(true, png.getData() != nullptr, "graya8 data");
|
|
|
}
|
|
|
|
|
|
static void testReadGrayA16(Test& test, const char* path) {
|
|
|
PNGReader png;
|
|
|
- if(png.load(StringBuffer<200>(path).append("graya16.png")).has()) {
|
|
|
- test.checkEqual(false, true, "read graya16 error");
|
|
|
- return;
|
|
|
- }
|
|
|
- test.checkEqual(32, png.getWidth(), "graya16 width");
|
|
|
- test.checkEqual(64, png.getHeight(), "graya16 height");
|
|
|
- test.checkEqual(2, png.getChannels(), "graya16 channels");
|
|
|
- test.checkEqual(32 * 64 * 2, png.getBufferSize(), "graya16 channels");
|
|
|
- testRead(test, png, "graya16 read");
|
|
|
+ test.checkEqual(
|
|
|
+ true, png.load(StringBuffer<200>(path).append("graya16.png")).has(),
|
|
|
+ "read graya16 error");
|
|
|
}
|
|
|
|
|
|
void PNGReaderTests::test(const char* path) {
|