Mercurial > hg > orthanc
diff UnitTestsSources/ImageTests.cpp @ 3837:963ea9fab402
merge
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 15 Apr 2020 17:28:27 +0200 |
parents | 219de90c1f43 |
children |
line wrap: on
line diff
--- a/UnitTestsSources/ImageTests.cpp Wed Apr 15 17:28:15 2020 +0200 +++ b/UnitTestsSources/ImageTests.cpp Wed Apr 15 17:28:27 2020 +0200 @@ -410,6 +410,28 @@ } { + // true means "enforce alignment by using a temporary buffer" + Orthanc::PamReader r(true); + r.ReadFromMemory(s); + + ASSERT_EQ(r.GetFormat(), Orthanc::PixelFormat_Grayscale16); + ASSERT_EQ(r.GetWidth(), width); + ASSERT_EQ(r.GetHeight(), height); + + v = 0; + for (unsigned int y = 0; y < height; y++) + { + const uint16_t* p = reinterpret_cast<const uint16_t*> + ((const uint8_t*)r.GetConstBuffer() + y * r.GetPitch()); + ASSERT_EQ(p, r.GetConstRow(y)); + for (unsigned int x = 0; x < width; x++, p++, v++) + { + ASSERT_EQ(v, *p); + } + } + } + + { Orthanc::TemporaryFile tmp; tmp.Write(s); @@ -432,4 +454,30 @@ } } } + + { + Orthanc::TemporaryFile tmp; + tmp.Write(s); + + // true means "enforce alignment by using a temporary buffer" + Orthanc::PamReader r2(true); + r2.ReadFromFile(tmp.GetPath()); + + ASSERT_EQ(r2.GetFormat(), Orthanc::PixelFormat_Grayscale16); + ASSERT_EQ(r2.GetWidth(), width); + ASSERT_EQ(r2.GetHeight(), height); + + v = 0; + for (unsigned int y = 0; y < height; y++) + { + const uint16_t* p = reinterpret_cast<const uint16_t*> + ((const uint8_t*)r2.GetConstBuffer() + y * r2.GetPitch()); + ASSERT_EQ(p, r2.GetConstRow(y)); + for (unsigned int x = 0; x < width; x++, p++, v++) + { + ASSERT_EQ(*p, v); + } + } + } + }