comparison OrthancFramework/UnitTestsSources/DicomMapTests.cpp @ 5040:1c08cd68250a

removed the 'name' of MainDicomTags to simplify code -> DicomMap::ParseMainDicomTags has been deprecated and one should use DicomMap::FromDicomAsJson on 'full' formatted tags
author Alain Mazy <am@osimis.io>
date Mon, 27 Jun 2022 12:39:51 +0200
parents 877bc3b96476
children 6fed78e13233
comparison
equal deleted inserted replaced
5039:28db9663fc2d 5040:1c08cd68250a
115 } 115 }
116 } 116 }
117 117
118 TEST_F(DicomMapMainTagsTests, AddMainTags) 118 TEST_F(DicomMapMainTagsTests, AddMainTags)
119 { 119 {
120 DicomMap::AddMainDicomTag(DICOM_TAG_BITS_ALLOCATED, "BitsAllocated", ResourceType_Instance); 120 DicomMap::AddMainDicomTag(DICOM_TAG_BITS_ALLOCATED, ResourceType_Instance);
121 121
122 { 122 {
123 const std::set<DicomTag>& s = DicomMap::GetMainDicomTags(ResourceType_Instance); 123 const std::set<DicomTag>& s = DicomMap::GetMainDicomTags(ResourceType_Instance);
124 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_BITS_ALLOCATED)); 124 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_BITS_ALLOCATED));
125 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID)); 125 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID));
131 131
132 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_BITS_ALLOCATED)); 132 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_BITS_ALLOCATED));
133 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_BITS_ALLOCATED, ResourceType_Instance)); 133 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_BITS_ALLOCATED, ResourceType_Instance));
134 134
135 // adding the same tag should throw 135 // adding the same tag should throw
136 ASSERT_THROW(DicomMap::AddMainDicomTag(DICOM_TAG_BITS_ALLOCATED, "BitsAllocated", ResourceType_Instance), OrthancException); 136 ASSERT_THROW(DicomMap::AddMainDicomTag(DICOM_TAG_BITS_ALLOCATED, ResourceType_Instance), OrthancException);
137 137
138 // adding another tag with same name should throw
139 ASSERT_THROW(DicomMap::AddMainDicomTag(DICOM_TAG_BITS_STORED, "BitsAllocated", ResourceType_Instance), OrthancException);
140 } 138 }
141 139
142 TEST_F(DicomMapMainTagsTests, Signatures) 140 TEST_F(DicomMapMainTagsTests, Signatures)
143 { 141 {
144 std::string defaultPatientSignature = DicomMap::GetDefaultMainDicomTagsSignature(ResourceType_Patient); 142 std::string defaultPatientSignature = DicomMap::GetDefaultMainDicomTagsSignature(ResourceType_Patient);
159 ASSERT_EQ(defaultPatientSignature, patientSignature); 157 ASSERT_EQ(defaultPatientSignature, patientSignature);
160 ASSERT_EQ(defaultStudySignature, studySignature); 158 ASSERT_EQ(defaultStudySignature, studySignature);
161 ASSERT_EQ(defaultSeriesSignature, seriesSignature); 159 ASSERT_EQ(defaultSeriesSignature, seriesSignature);
162 ASSERT_EQ(defaultInstanceSignature, instanceSignature); 160 ASSERT_EQ(defaultInstanceSignature, instanceSignature);
163 161
164 DicomMap::AddMainDicomTag(DICOM_TAG_BITS_ALLOCATED, "BitsAllocated", ResourceType_Instance); 162 DicomMap::AddMainDicomTag(DICOM_TAG_BITS_ALLOCATED, ResourceType_Instance);
165 instanceSignature = DicomMap::GetMainDicomTagsSignature(ResourceType_Instance); 163 instanceSignature = DicomMap::GetMainDicomTagsSignature(ResourceType_Instance);
166 164
167 ASSERT_NE(defaultInstanceSignature, instanceSignature); 165 ASSERT_NE(defaultInstanceSignature, instanceSignature);
168 } 166 }
169 167
791 ASSERT_EQ(Json::objectValue, json.type()); 789 ASSERT_EQ(Json::objectValue, json.type());
792 ASSERT_EQ(1u, json.getMemberNames().size()); 790 ASSERT_EQ(1u, json.getMemberNames().size());
793 791
794 std::string name = json.getMemberNames() [0]; 792 std::string name = json.getMemberNames() [0];
795 EXPECT_EQ(name, FromDcmtkBridge::GetTagName(*it, "")); 793 EXPECT_EQ(name, FromDcmtkBridge::GetTagName(*it, ""));
796
797 DicomMap b;
798 b.ParseMainDicomTags(json, level);
799
800 ASSERT_EQ(1u, b.GetSize());
801 ASSERT_EQ("TEST", b.GetStringValue(*it, "", false));
802 794
803 std::string main = FromDcmtkBridge::GetTagName(*it, ""); 795 std::string main = FromDcmtkBridge::GetTagName(*it, "");
804 if (!main.empty()) 796 if (!main.empty())
805 { 797 {
806 ASSERT_EQ(main, name); 798 ASSERT_EQ(main, name);