Mercurial > hg > orthanc
comparison UnitTestsSources/DicomMap.cpp @ 762:45b16f67259c lua-scripting
integration mainline -> lua-scripting
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 Apr 2014 16:47:21 +0200 |
parents | 8f62e8d5a384 |
children | 3d6f9b7d0add |
comparison
equal
deleted
inserted
replaced
409:63f707278fc8 | 762:45b16f67259c |
---|---|
1 #include "gtest/gtest.h" | |
2 | |
3 #include "../Core/Uuid.h" | |
4 #include "../Core/OrthancException.h" | |
5 #include "../Core/DicomFormat/DicomMap.h" | |
6 #include "../Core/DicomFormat/DicomNullValue.h" | |
7 | |
8 #include <memory> | |
9 | |
10 using namespace Orthanc; | |
11 | |
12 TEST(DicomMap, MainTags) | |
13 { | |
14 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID)); | |
15 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Patient)); | |
16 ASSERT_FALSE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Study)); | |
17 | |
18 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_STUDY_INSTANCE_UID)); | |
19 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_ACCESSION_NUMBER)); | |
20 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SERIES_INSTANCE_UID)); | |
21 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SOP_INSTANCE_UID)); | |
22 | |
23 std::set<DicomTag> s; | |
24 DicomMap::GetMainDicomTags(s); | |
25 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID)); | |
26 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID)); | |
27 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER)); | |
28 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID)); | |
29 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID)); | |
30 | |
31 DicomMap::GetMainDicomTags(s, ResourceType_Patient); | |
32 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID)); | |
33 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_STUDY_INSTANCE_UID)); | |
34 | |
35 DicomMap::GetMainDicomTags(s, ResourceType_Study); | |
36 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID)); | |
37 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER)); | |
38 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID)); | |
39 | |
40 DicomMap::GetMainDicomTags(s, ResourceType_Series); | |
41 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID)); | |
42 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID)); | |
43 | |
44 DicomMap::GetMainDicomTags(s, ResourceType_Instance); | |
45 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID)); | |
46 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID)); | |
47 } | |
48 | |
49 | |
50 TEST(DicomMap, Tags) | |
51 { | |
52 DicomMap m; | |
53 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_NAME)); | |
54 ASSERT_FALSE(m.HasTag(0x0010, 0x0010)); | |
55 m.SetValue(0x0010, 0x0010, "PatientName"); | |
56 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_NAME)); | |
57 ASSERT_TRUE(m.HasTag(0x0010, 0x0010)); | |
58 | |
59 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_ID)); | |
60 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID"); | |
61 ASSERT_TRUE(m.HasTag(0x0010, 0x0020)); | |
62 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID2"); | |
63 ASSERT_EQ("PatientID2", m.GetValue(0x0010, 0x0020).AsString()); | |
64 | |
65 m.Remove(DICOM_TAG_PATIENT_ID); | |
66 ASSERT_THROW(m.GetValue(0x0010, 0x0020), OrthancException); | |
67 | |
68 std::auto_ptr<DicomMap> mm(m.Clone()); | |
69 ASSERT_EQ("PatientName", mm->GetValue(DICOM_TAG_PATIENT_NAME).AsString()); | |
70 | |
71 m.SetValue(DICOM_TAG_PATIENT_ID, "Hello"); | |
72 ASSERT_THROW(mm->GetValue(DICOM_TAG_PATIENT_ID), OrthancException); | |
73 mm->CopyTagIfExists(m, DICOM_TAG_PATIENT_ID); | |
74 ASSERT_EQ("Hello", mm->GetValue(DICOM_TAG_PATIENT_ID).AsString()); | |
75 | |
76 DicomNullValue v; | |
77 ASSERT_TRUE(v.IsNull()); | |
78 } | |
79 | |
80 | |
81 TEST(DicomMap, FindTemplates) | |
82 { | |
83 DicomMap m; | |
84 | |
85 DicomMap::SetupFindPatientTemplate(m); | |
86 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_ID)); | |
87 | |
88 DicomMap::SetupFindStudyTemplate(m); | |
89 ASSERT_TRUE(m.HasTag(DICOM_TAG_STUDY_INSTANCE_UID)); | |
90 ASSERT_TRUE(m.HasTag(DICOM_TAG_ACCESSION_NUMBER)); | |
91 | |
92 DicomMap::SetupFindSeriesTemplate(m); | |
93 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_INSTANCE_UID)); | |
94 | |
95 DicomMap::SetupFindInstanceTemplate(m); | |
96 ASSERT_TRUE(m.HasTag(DICOM_TAG_SOP_INSTANCE_UID)); | |
97 } |