Mercurial > hg > orthanc
comparison UnitTestsSources/FromDcmtkTests.cpp @ 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 | c6658187e4b1 |
children | 5bba4d249422 |
comparison
equal
deleted
inserted
replaced
3831:83ea6939293d | 3832:ab9a0d1e0cc1 |
---|---|
708 | 708 |
709 | 709 |
710 TEST(ParsedDicomFile, ToJsonFlags2) | 710 TEST(ParsedDicomFile, ToJsonFlags2) |
711 { | 711 { |
712 ParsedDicomFile f(true); | 712 ParsedDicomFile f(true); |
713 f.Insert(DICOM_TAG_PIXEL_DATA, "Pixels", false, ""); | 713 |
714 { | |
715 // "ParsedDicomFile" uses Little Endian => 'B' (least significant | |
716 // byte) will be stored first in the memory buffer and in the | |
717 // file, then 'A'. Hence the expected "BA" value below. | |
718 Uint16 v[] = { 'A' * 256 + 'B', 0 }; | |
719 ASSERT_TRUE(f.GetDcmtkObject().getDataset()->putAndInsertUint16Array(DCM_PixelData, v, 2).good()); | |
720 } | |
714 | 721 |
715 Json::Value v; | 722 Json::Value v; |
716 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); | 723 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
717 ASSERT_EQ(Json::objectValue, v.type()); | 724 ASSERT_EQ(Json::objectValue, v.type()); |
718 ASSERT_EQ(5u, v.getMemberNames().size()); | 725 ASSERT_EQ(5u, v.getMemberNames().size()); |
727 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePixelData | DicomToJsonFlags_ConvertBinaryToAscii), 0); | 734 f.DatasetToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludePixelData | DicomToJsonFlags_ConvertBinaryToAscii), 0); |
728 ASSERT_EQ(Json::objectValue, v.type()); | 735 ASSERT_EQ(Json::objectValue, v.type()); |
729 ASSERT_EQ(6u, v.getMemberNames().size()); | 736 ASSERT_EQ(6u, v.getMemberNames().size()); |
730 ASSERT_TRUE(v.isMember("7fe0,0010")); | 737 ASSERT_TRUE(v.isMember("7fe0,0010")); |
731 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type()); | 738 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type()); |
732 ASSERT_EQ("Pixels", v["7fe0,0010"].asString()); | 739 ASSERT_EQ("BA", v["7fe0,0010"].asString().substr(0, 2)); |
733 | 740 |
734 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePixelData, 0); | 741 f.DatasetToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePixelData, 0); |
735 ASSERT_EQ(Json::objectValue, v.type()); | 742 ASSERT_EQ(Json::objectValue, v.type()); |
736 ASSERT_EQ(6u, v.getMemberNames().size()); | 743 ASSERT_EQ(6u, v.getMemberNames().size()); |
737 ASSERT_TRUE(v.isMember("7fe0,0010")); | 744 ASSERT_TRUE(v.isMember("7fe0,0010")); |
738 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type()); | 745 ASSERT_EQ(Json::stringValue, v["7fe0,0010"].type()); |
739 std::string mime, content; | 746 std::string mime, content; |
740 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7fe0,0010"].asString())); | 747 ASSERT_TRUE(Toolbox::DecodeDataUriScheme(mime, content, v["7fe0,0010"].asString())); |
741 ASSERT_EQ("application/octet-stream", mime); | 748 ASSERT_EQ("application/octet-stream", mime); |
742 ASSERT_EQ("Pixels", content); | 749 ASSERT_EQ("BA", content.substr(0, 2)); |
743 } | 750 } |
744 | 751 |
745 | 752 |
746 TEST(DicomFindAnswers, Basic) | 753 TEST(DicomFindAnswers, Basic) |
747 { | 754 { |