comparison UnitTestsSources/DicomMapTests.cpp @ 3651:46cb00e4adbb

DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Feb 2020 13:22:02 +0100
parents 94f4a18a79cc
children 4922bdd046dd
comparison
equal deleted inserted replaced
3650:e5811a9f8df0 3651:46cb00e4adbb
989 989
990 std::string s; 990 std::string s;
991 ASSERT_TRUE(target.LookupStringValue(s, DICOM_TAG_PIXEL_SPACING, false)); 991 ASSERT_TRUE(target.LookupStringValue(s, DICOM_TAG_PIXEL_SPACING, false));
992 ASSERT_EQ(s, "1.5\\1.3"); 992 ASSERT_EQ(s, "1.5\\1.3");
993 } 993 }
994
995
996 TEST(DicomMap, MainTagNames)
997 {
998 ASSERT_EQ(3, ResourceType_Instance - ResourceType_Patient);
999
1000 for (int i = ResourceType_Patient; i <= ResourceType_Instance; i++)
1001 {
1002 ResourceType level = static_cast<ResourceType>(i);
1003
1004 std::set<DicomTag> tags;
1005 DicomMap::GetMainDicomTags(tags, level);
1006
1007 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
1008 {
1009 DicomMap a;
1010 a.SetValue(*it, "TEST", false);
1011
1012 Json::Value json;
1013 a.DumpMainDicomTags(json, level);
1014
1015 ASSERT_EQ(Json::objectValue, json.type());
1016 ASSERT_EQ(1u, json.getMemberNames().size());
1017
1018 std::string name = json.getMemberNames() [0];
1019 EXPECT_EQ(name, FromDcmtkBridge::GetTagName(*it, ""));
1020
1021 DicomMap b;
1022 b.ParseMainDicomTags(json, level);
1023
1024 ASSERT_EQ(1u, b.GetSize());
1025 ASSERT_EQ("TEST", b.GetStringValue(*it, "", false));
1026
1027 std::string main = it->GetMainTagsName();
1028 if (!main.empty())
1029 {
1030 ASSERT_EQ(main, name);
1031 }
1032 }
1033 }
1034 }