Mercurial > hg > orthanc
diff UnitTestsSources/FromDcmtkTests.cpp @ 1307:f796207e3df1
Fix replacement and insertion of private DICOM tags
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 11 Feb 2015 10:26:17 +0100 |
parents | 6e7e5ed91c2d |
children | 7f0aa3c0f659 |
line wrap: on
line diff
--- a/UnitTestsSources/FromDcmtkTests.cpp Tue Feb 10 17:17:25 2015 +0100 +++ b/UnitTestsSources/FromDcmtkTests.cpp Wed Feb 11 10:26:17 2015 +0100 @@ -89,14 +89,35 @@ TEST(DicomModification, Anonymization) { + ASSERT_EQ(DICOM_TAG_PATIENT_NAME, FromDcmtkBridge::ParseTag("PatientName")); + const DicomTag privateTag(0x0045, 0x0010); + const DicomTag privateTag2(FromDcmtkBridge::ParseTag("0031-1020")); ASSERT_TRUE(FromDcmtkBridge::IsPrivateTag(privateTag)); + ASSERT_TRUE(FromDcmtkBridge::IsPrivateTag(privateTag2)); + ASSERT_EQ(0x0031, privateTag2.GetGroup()); + ASSERT_EQ(0x1020, privateTag2.GetElement()); + std::string s; ParsedDicomFile o; o.Replace(DICOM_TAG_PATIENT_NAME, "coucou"); - o.Replace(privateTag, "private tag"); + ASSERT_FALSE(o.GetTagValue(s, privateTag)); + o.Insert(privateTag, "private tag"); + ASSERT_TRUE(o.GetTagValue(s, privateTag)); + ASSERT_STREQ("private tag", s.c_str()); - std::string s; + ASSERT_FALSE(o.GetTagValue(s, privateTag2)); + ASSERT_THROW(o.Replace(privateTag2, "hello", DicomReplaceMode_ThrowIfAbsent), OrthancException); + ASSERT_FALSE(o.GetTagValue(s, privateTag2)); + o.Replace(privateTag2, "hello", DicomReplaceMode_IgnoreIfAbsent); + ASSERT_FALSE(o.GetTagValue(s, privateTag2)); + o.Replace(privateTag2, "hello", DicomReplaceMode_InsertIfAbsent); + ASSERT_TRUE(o.GetTagValue(s, privateTag2)); + ASSERT_STREQ("hello", s.c_str()); + o.Replace(privateTag2, "hello world"); + ASSERT_TRUE(o.GetTagValue(s, privateTag2)); + ASSERT_STREQ("hello world", s.c_str()); + ASSERT_TRUE(o.GetTagValue(s, DICOM_TAG_PATIENT_NAME)); ASSERT_FALSE(Toolbox::IsUuid(s)); @@ -109,7 +130,7 @@ ASSERT_TRUE(o.GetTagValue(s, DICOM_TAG_PATIENT_NAME)); ASSERT_TRUE(Toolbox::IsUuid(s)); ASSERT_TRUE(o.GetTagValue(s, privateTag)); - ASSERT_EQ("private tag", s); + ASSERT_STREQ("private tag", s.c_str()); m.SetupAnonymization(); m.Apply(o);