changeset 3832:ab9a0d1e0cc1

Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 15 Apr 2020 14:37:40 +0200
parents 83ea6939293d
children a3e38994d95a
files NEWS UnitTestsSources/FromDcmtkTests.cpp
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Apr 10 17:56:12 2020 +0200
+++ b/NEWS	Wed Apr 15 14:37:40 2020 +0200
@@ -19,6 +19,7 @@
 * Fix lookup form in Orthanc Explorer (wildcards not allowed in StudyDate)
 * Fix signature of "OrthancPluginRegisterStorageCommitmentScpCallback()" in plugins SDK
 * Error reporting on failure while initializing SSL
+* Fix unit test ParsedDicomFile.ToJsonFlags2 on big-endian architectures
 * Upgraded dependencies for static builds (notably on Windows):
   - civetweb 1.12
   - openssl 1.1.1f
--- a/UnitTestsSources/FromDcmtkTests.cpp	Fri Apr 10 17:56:12 2020 +0200
+++ b/UnitTestsSources/FromDcmtkTests.cpp	Wed Apr 15 14:37:40 2020 +0200
@@ -710,7 +710,14 @@
 TEST(ParsedDicomFile, ToJsonFlags2)
 {
   ParsedDicomFile f(true);
-  f.Insert(DICOM_TAG_PIXEL_DATA, "Pixels", false, "");
+
+  {
+    // "ParsedDicomFile" uses Little Endian => 'B' (least significant
+    // byte) will be stored first in the memory buffer and in the
+    // file, then 'A'. Hence the expected "BA" value below.
+    Uint16 v[] = { 'A' * 256 + 'B', 0 };
+    ASSERT_TRUE(f.GetDcmtkObject().getDataset()->putAndInsertUint16Array(DCM_PixelData, v, 2).good());
+  }
 
   Json::Value v;
   f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0);
@@ -729,7 +736,7 @@
   ASSERT_EQ(6u, v.getMemberNames().size());
   ASSERT_TRUE(v.isMember("7fe0,0010"));  
   ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type());  
-  ASSERT_EQ("Pixels", v["7fe0,0010"].asString());  
+  ASSERT_EQ("BA", v["7fe0,0010"].asString().substr(0, 2));
 
   f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePixelData, 0);
   ASSERT_EQ(Json::objectValue, v.type());
@@ -739,7 +746,7 @@
   std::string mime, content;
   ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7fe0,0010"].asString()));
   ASSERT_EQ("application/octet-stream", mime);
-  ASSERT_EQ("Pixels", content);
+  ASSERT_EQ("BA", content.substr(0, 2));
 }