annotate UnitTestsSources/DicomMapTests.cpp @ 1276:6164f7200c43

refactoring modules
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 23 Jan 2015 14:42:33 +0100
parents dfc076546821
children 6e7e5ed91c2d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
827
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
1 /**
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege,
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
4 * Belgium
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
5 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
6 * This program is free software: you can redistribute it and/or
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
7 * modify it under the terms of the GNU General Public License as
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
9 * License, or (at your option) any later version.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
10 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
11 * In addition, as a special exception, the copyright holders of this
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
12 * program give permission to link the code of its release with the
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
15 * the linked executables. You must obey the GNU General Public License
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
19 * you do not wish to do so, delete this exception statement from your
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
20 * version. If you delete this exception statement from all source files
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
21 * in the program, then also delete it here.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
22 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
23 * This program is distributed in the hope that it will be useful, but
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
26 * General Public License for more details.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
27 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
28 * You should have received a copy of the GNU General Public License
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
30 **/
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
31
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
32
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 827
diff changeset
33 #include "PrecompiledHeadersUnitTests.h"
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "gtest/gtest.h"
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../Core/Uuid.h"
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../Core/OrthancException.h"
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../Core/DicomFormat/DicomMap.h"
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include "../Core/DicomFormat/DicomNullValue.h"
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
40 #include "../OrthancServer/FromDcmtkBridge.h"
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <memory>
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 using namespace Orthanc;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 TEST(DicomMap, MainTags)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Patient));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 ASSERT_FALSE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Study));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 std::set<DicomTag> s;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 DicomMap::GetMainDicomTags(s);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 DicomMap::GetMainDicomTags(s, ResourceType_Patient);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 DicomMap::GetMainDicomTags(s, ResourceType_Study);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 DicomMap::GetMainDicomTags(s, ResourceType_Series);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 DicomMap::GetMainDicomTags(s, ResourceType_Instance);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 TEST(DicomMap, Tags)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 {
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 DicomMap m;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_NAME));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 ASSERT_FALSE(m.HasTag(0x0010, 0x0010));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 m.SetValue(0x0010, 0x0010, "PatientName");
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_NAME));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 ASSERT_TRUE(m.HasTag(0x0010, 0x0010));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID");
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 ASSERT_TRUE(m.HasTag(0x0010, 0x0020));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID2");
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 ASSERT_EQ("PatientID2", m.GetValue(0x0010, 0x0020).AsString());
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 m.Remove(DICOM_TAG_PATIENT_ID);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 ASSERT_THROW(m.GetValue(0x0010, 0x0020), OrthancException);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 std::auto_ptr<DicomMap> mm(m.Clone());
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 ASSERT_EQ("PatientName", mm->GetValue(DICOM_TAG_PATIENT_NAME).AsString());
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 m.SetValue(DICOM_TAG_PATIENT_ID, "Hello");
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 ASSERT_THROW(mm->GetValue(DICOM_TAG_PATIENT_ID), OrthancException);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 mm->CopyTagIfExists(m, DICOM_TAG_PATIENT_ID);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 ASSERT_EQ("Hello", mm->GetValue(DICOM_TAG_PATIENT_ID).AsString());
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 DicomNullValue v;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 ASSERT_TRUE(v.IsNull());
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 TEST(DicomMap, FindTemplates)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 DicomMap m;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 DicomMap::SetupFindPatientTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 DicomMap::SetupFindStudyTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 ASSERT_TRUE(m.HasTag(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 ASSERT_TRUE(m.HasTag(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 DicomMap::SetupFindSeriesTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 DicomMap::SetupFindInstanceTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 ASSERT_TRUE(m.HasTag(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
132
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
133
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
134
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
135
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
136 static void TestModule(ResourceType level,
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
137 DicomModule module)
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
138 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
139 std::set<DicomTag> moduleTags, main;
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
140 DicomTag::GetTagsForModule(moduleTags, module);
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
141 DicomMap::GetMainDicomTags(main, level);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
142
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
143 // The main dicom tags are a subset of the module
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
144 for (std::set<DicomTag>::const_iterator it = main.begin(); it != main.end(); it++)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
145 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
146 bool ok = moduleTags.find(*it) != moduleTags.end();
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
147
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
148 // Exceptions for the Series level
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
149 /*if ((//
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
150 *it == DicomTag(0x, 0x) &&
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
151 level == ResourceType_Series))
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
152 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
153 ok = true;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
154 }*/
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
155
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
156 // Exceptions for the Instance level
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
157 if ((/* Accession number, from Image module */
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
158 *it == DicomTag(0x0020, 0x0012) &&
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
159 level == ResourceType_Instance) ||
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
160 (/* Image Index, from PET Image module */
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
161 *it == DicomTag(0x0054, 0x1330) &&
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
162 level == ResourceType_Instance) ||
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
163 (/* Temporal Position Identifier, from MR Image module */
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
164 *it == DicomTag(0x0020, 0x0100) &&
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
165 level == ResourceType_Instance) ||
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
166 (/* Number of Frames, from Multi-frame module attributes, related to Image IOD */
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
167 *it == DicomTag(0x0028, 0x0008) &&
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
168 level == ResourceType_Instance ))
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
169 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
170 ok = true;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
171 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
172
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
173 if (!ok)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
174 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
175 std::cout << it->Format() << ": " << FromDcmtkBridge::GetName(*it)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
176 << " not expected at level " << EnumerationToString(level) << std::endl;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
177 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
178
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
179 EXPECT_TRUE(ok);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
180 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
181 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
182
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
183
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
184 TEST(DicomMap, Modules)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
185 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
186 TestModule(ResourceType_Patient, DicomModule_Patient);
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
187 TestModule(ResourceType_Study, DicomModule_Study);
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
188 //TestModule(ResourceType_Series, DicomModule_Series); // TODO
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
189 TestModule(ResourceType_Instance, DicomModule_Instance);
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
190 }