|
@@ -1,15 +1,16 @@
|
|
|
#include "tests/PNGReaderTests.h"
|
|
|
-#include "tests/Test.h"
|
|
|
#include "images/PNGReader.h"
|
|
|
+#include "tests/Test.h"
|
|
|
+#include "utils/List.h"
|
|
|
#include "utils/StringBuffer.h"
|
|
|
-#include "memory/StackAllocator.h"
|
|
|
|
|
|
static void testRead(Test& test, PNGReader& png, const char* text) {
|
|
|
- StackAllocator::Array<ColorChannel> buffer(png.getBufferSize());
|
|
|
+ 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), text);
|
|
|
+ test.checkEqual(false, png.readData(buffer.begin()), text);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -34,7 +35,7 @@ static void testReadRGB16(Test& test, const char* path) {
|
|
|
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, png.getBufferSize(), "rgb16 channels");
|
|
|
+ test.checkEqual(32 * 64 * 3, png.getBufferSize(), "rgb16 channels");
|
|
|
testRead(test, png, "rgb16 read");
|
|
|
}
|
|
|
|
|
@@ -47,7 +48,7 @@ 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, png.getBufferSize(), "rgba8 channels");
|
|
|
+ test.checkEqual(32 * 64 * 4, png.getBufferSize(), "rgba8 channels");
|
|
|
testRead(test, png, "rgba8 read");
|
|
|
}
|
|
|
|
|
@@ -60,7 +61,7 @@ static void testReadRGBA16(Test& test, const char* path) {
|
|
|
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, png.getBufferSize(), "rgba16 channels");
|
|
|
+ test.checkEqual(32 * 64 * 4, png.getBufferSize(), "rgba16 channels");
|
|
|
testRead(test, png, "rgba16 read");
|
|
|
}
|
|
|
|
|
@@ -99,7 +100,7 @@ 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, png.getBufferSize(), "graya8 channels");
|
|
|
+ test.checkEqual(32 * 64 * 2, png.getBufferSize(), "graya8 channels");
|
|
|
testRead(test, png, "graya8 read");
|
|
|
}
|
|
|
|
|
@@ -112,7 +113,7 @@ static void testReadGrayA16(Test& test, const char* path) {
|
|
|
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, png.getBufferSize(), "graya16 channels");
|
|
|
+ test.checkEqual(32 * 64 * 2, png.getBufferSize(), "graya16 channels");
|
|
|
testRead(test, png, "graya16 read");
|
|
|
}
|
|
|
|