# HG changeset patch # User Sebastien Jodogne # Date 1392300398 -3600 # Node ID 6c90ce085261971b17bd9291db48dded68c006a5 # Parent 38e2883e096f203b9803456e82d7a59e93059bd7 zlib tests diff -r 38e2883e096f -r 6c90ce085261 UnitTestsSources/Png.cpp --- a/UnitTestsSources/Png.cpp Thu Feb 13 14:57:57 2014 +0100 +++ b/UnitTestsSources/Png.cpp Thu Feb 13 15:06:38 2014 +0100 @@ -4,6 +4,7 @@ #include "../Core/FileFormats/PngReader.h" #include "../Core/FileFormats/PngWriter.h" #include "../Core/Toolbox.h" +#include "../Core/Uuid.h" TEST(PngWriter, ColorPattern) @@ -107,19 +108,40 @@ std::string s; w.WriteToMemory(s, width, height, pitch, Orthanc::PixelFormat_Grayscale16, &image[0]); - Orthanc::PngReader r; - r.ReadFromMemory(s); + { + Orthanc::PngReader r; + r.ReadFromMemory(s); - ASSERT_EQ(r.GetWidth(), width); - ASSERT_EQ(r.GetHeight(), height); + ASSERT_EQ(r.GetWidth(), width); + ASSERT_EQ(r.GetHeight(), height); - v = 0; - for (int y = 0; y < height; y++) + v = 0; + for (int y = 0; y < height; y++) + { + uint16_t *p = reinterpret_cast((uint8_t*) r.GetBuffer() + y * r.GetPitch()); + for (int x = 0; x < width; x++, p++, v++) + { + ASSERT_EQ(*p, v); + } + } + } + { - uint16_t *p = reinterpret_cast((uint8_t*) r.GetBuffer() + y * r.GetPitch()); - for (int x = 0; x < width; x++, p++, v++) + Toolbox::TemporaryFile tmp; + Toolbox::WriteFile(s, tmp.GetPath()); + + Orthanc::PngReader r2; + r2.ReadFromFile(tmp.GetPath()); + + ASSERT_EQ(r2.GetWidth(), width); + ASSERT_EQ(r2.GetHeight(), height); + for (int y = 0; y < height; y++) { - ASSERT_EQ(*p, v); + uint16_t *p = reinterpret_cast((uint8_t*) r2.GetBuffer() + y * r2.GetPitch()); + for (int x = 0; x < width; x++, p++, v++) + { + ASSERT_EQ(*p, v); + } } } }