annotate OrthancFramework/UnitTestsSources/DicomMapTests.cpp @ 4062:0953b3dc3261 framework

pretty-printing
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 11 Jun 2020 14:38:31 +0200
parents 8b7cd69806f2
children e00f3d089991
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
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1850
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1276
diff changeset
4 * Department, University Hospital of Liege, Belgium
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3581
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
827
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
6 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
7 * 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
8 * 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
9 * 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
10 * License, or (at your option) any later version.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
11 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
12 * 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
13 * 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
14 * 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
15 * 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
16 * 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
17 * 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
18 * 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
19 * 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
20 * 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
21 * 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
22 * in the program, then also delete it here.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
23 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
24 * 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
25 * 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
26 * 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
27 * General Public License for more details.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
28 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
29 * 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
30 * 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
31 **/
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
32
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 711
diff changeset
33
4057
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
34 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
35 # include <OrthancFramework.h>
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
36 #endif
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
37
4062
0953b3dc3261 pretty-printing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4057
diff changeset
38 #include <gtest/gtest.h>
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
4057
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
40 #include "../Sources/Compatibility.h"
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
41 #include "../Sources/OrthancException.h"
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
42 #include "../Sources/DicomFormat/DicomMap.h"
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
43 #include "../Sources/DicomParsing/FromDcmtkBridge.h"
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
44 #include "../Sources/DicomParsing/ToDcmtkBridge.h"
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
45 #include "../Sources/DicomParsing/ParsedDicomFile.h"
8b7cd69806f2 move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
46 #include "../Sources/DicomParsing/DicomWebJsonVisitor.h"
711
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 #include <memory>
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
49 #include <dcmtk/dcmdata/dcdeftag.h>
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
50 #include <dcmtk/dcmdata/dcvrat.h>
711
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 using namespace Orthanc;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 TEST(DicomMap, MainTags)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Patient));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 ASSERT_FALSE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Study));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 ASSERT_TRUE(DicomMap::IsMainDicomTag(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 std::set<DicomTag> s;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 DicomMap::GetMainDicomTags(s);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 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
69 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 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
71 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
72
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 DicomMap::GetMainDicomTags(s, ResourceType_Patient);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 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
76
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 DicomMap::GetMainDicomTags(s, ResourceType_Study);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 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
79 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER));
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 DicomMap::GetMainDicomTags(s, ResourceType_Series);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 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
84 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
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::GetMainDicomTags(s, ResourceType_Instance);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 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
88 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 TEST(DicomMap, Tags)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 {
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
94 std::set<DicomTag> s;
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
95
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 DicomMap m;
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
97 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
98 ASSERT_EQ(0u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
99
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_NAME));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 ASSERT_FALSE(m.HasTag(0x0010, 0x0010));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
102 m.SetValue(0x0010, 0x0010, "PatientName", false);
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_NAME));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 ASSERT_TRUE(m.HasTag(0x0010, 0x0010));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
106 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
107 ASSERT_EQ(1u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
108 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin());
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
109
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_ID));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
111 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID", false);
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 ASSERT_TRUE(m.HasTag(0x0010, 0x0020));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
113 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID2", false);
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
114 ASSERT_EQ("PatientID2", m.GetValue(0x0010, 0x0020).GetContent());
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
116 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
117 ASSERT_EQ(2u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
118
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 m.Remove(DICOM_TAG_PATIENT_ID);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 ASSERT_THROW(m.GetValue(0x0010, 0x0020), OrthancException);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
122 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
123 ASSERT_EQ(1u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
124 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin());
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
125
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
126 std::unique_ptr<DicomMap> mm(m.Clone());
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
127 ASSERT_EQ("PatientName", mm->GetValue(DICOM_TAG_PATIENT_NAME).GetContent());
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
129 m.SetValue(DICOM_TAG_PATIENT_ID, "Hello", false);
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 ASSERT_THROW(mm->GetValue(DICOM_TAG_PATIENT_ID), OrthancException);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 mm->CopyTagIfExists(m, DICOM_TAG_PATIENT_ID);
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
132 ASSERT_EQ("Hello", mm->GetValue(DICOM_TAG_PATIENT_ID).GetContent());
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
134 DicomValue v;
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 ASSERT_TRUE(v.IsNull());
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 TEST(DicomMap, FindTemplates)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 {
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 DicomMap m;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 DicomMap::SetupFindPatientTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 DicomMap::SetupFindStudyTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 ASSERT_TRUE(m.HasTag(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 ASSERT_TRUE(m.HasTag(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 DicomMap::SetupFindSeriesTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 DicomMap::SetupFindInstanceTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 ASSERT_TRUE(m.HasTag(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 }
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
156
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
157
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
158
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
159
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
160 static void TestModule(ResourceType level,
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
161 DicomModule module)
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
162 {
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
163 // REFERENCE: DICOM PS3.3 2015c - Information Object Definitions
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
164 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
165
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
166 std::set<DicomTag> moduleTags, main;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
167 DicomTag::AddTagsForModule(moduleTags, module);
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
168 DicomMap::GetMainDicomTags(main, level);
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 // The main dicom tags are a subset of the module
1304
7b6925b0890d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
171 for (std::set<DicomTag>::const_iterator it = main.begin(); it != main.end(); ++it)
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
172 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
173 bool ok = moduleTags.find(*it) != moduleTags.end();
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
174
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
175 // Exceptions for the Study level
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
176 if (level == ResourceType_Study &&
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
177 (*it == DicomTag(0x0008, 0x0080) || /* InstitutionName, from Visit identification module, related to Visit */
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
178 *it == DicomTag(0x0032, 0x1032) || /* RequestingPhysician, from Imaging Service Request module, related to Study */
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
179 *it == DicomTag(0x0032, 0x1060))) /* RequestedProcedureDescription, from Requested Procedure module, related to Study */
963
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 ok = true;
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
182 }
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
183
1849
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
184 // Exceptions for the Series level
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
185 if (level == ResourceType_Series &&
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
186 (*it == DicomTag(0x0008, 0x0070) || /* Manufacturer, from General Equipment Module */
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
187 *it == DicomTag(0x0008, 0x1010) || /* StationName, from General Equipment Module */
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
188 *it == DicomTag(0x0018, 0x0024) || /* SequenceName, from MR Image Module (SIMPLIFICATION => Series) */
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
189 *it == DicomTag(0x0018, 0x1090) || /* CardiacNumberOfImages, from MR Image Module (SIMPLIFICATION => Series) */
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
190 *it == DicomTag(0x0020, 0x0037) || /* ImageOrientationPatient, from Image Plane Module (SIMPLIFICATION => Series) */
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
191 *it == DicomTag(0x0020, 0x0105) || /* NumberOfTemporalPositions, from MR Image Module (SIMPLIFICATION => Series) */
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
192 *it == DicomTag(0x0020, 0x1002) || /* ImagesInAcquisition, from General Image Module (SIMPLIFICATION => Series) */
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
193 *it == DicomTag(0x0054, 0x0081) || /* NumberOfSlices, from PET Series module */
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
194 *it == DicomTag(0x0054, 0x0101) || /* NumberOfTimeSlices, from PET Series module */
1850
68854412c7bc new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1849
diff changeset
195 *it == DicomTag(0x0054, 0x1000) || /* SeriesType, from PET Series module */
68854412c7bc new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1849
diff changeset
196 *it == DicomTag(0x0018, 0x1400) || /* AcquisitionDeviceProcessingDescription, from CR/X-Ray/DX/WholeSlideMicro Image (SIMPLIFICATION => Series) */
68854412c7bc new main dicomtags: AcquisitionDeviceProcessingDescription and ContrastBolusAgent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1849
diff changeset
197 *it == DicomTag(0x0018, 0x0010))) /* ContrastBolusAgent, from Contrast/Bolus module (SIMPLIFICATION => Series) */
1849
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
198 {
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
199 ok = true;
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
200 }
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
201
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
202 // Exceptions for the Instance level
1704
d2268c7a7ede fix unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
203 if (level == ResourceType_Instance &&
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
204 (*it == DicomTag(0x0020, 0x0012) || /* AccessionNumber, from General Image module */
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
205 *it == DicomTag(0x0054, 0x1330) || /* ImageIndex, from PET Image module */
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
206 *it == DicomTag(0x0020, 0x0100) || /* TemporalPositionIdentifier, from MR Image module */
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
207 *it == DicomTag(0x0028, 0x0008) || /* NumberOfFrames, from Multi-frame module attributes, related to Image */
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
208 *it == DicomTag(0x0020, 0x0032) || /* ImagePositionPatient, from Image Plan module, related to Image */
2804
d88970f1ffbf fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
209 *it == DicomTag(0x0020, 0x0037) || /* ImageOrientationPatient, from Image Plane Module (Orthanc 1.4.2) */
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
210 *it == DicomTag(0x0020, 0x4000))) /* ImageComments, from General Image module */
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
211 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
212 ok = true;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
213 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
214
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
215 if (!ok)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
216 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
217 std::cout << it->Format() << ": " << FromDcmtkBridge::GetTagName(*it, "")
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
218 << " not expected at level " << EnumerationToString(level) << std::endl;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
219 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
220
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
221 EXPECT_TRUE(ok);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
222 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
223 }
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
224
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
225
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
226 TEST(DicomMap, Modules)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
227 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
228 TestModule(ResourceType_Patient, DicomModule_Patient);
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
229 TestModule(ResourceType_Study, DicomModule_Study);
1849
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
230 TestModule(ResourceType_Series, DicomModule_Series); // TODO
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
231 TestModule(ResourceType_Instance, DicomModule_Instance);
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
232 }
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
233
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
234
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
235 TEST(DicomMap, Parse)
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
236 {
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
237 DicomMap m;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
238 float f;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
239 double d;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
240 int32_t i;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
241 int64_t j;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
242 uint32_t k;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
243 uint64_t l;
3519
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
244 unsigned int ui;
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
245 std::string s;
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
246
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
247 m.SetValue(DICOM_TAG_PATIENT_NAME, " ", false); // Empty value
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
248 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
249 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
250 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
251 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
252 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
253 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
254
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
255 m.SetValue(DICOM_TAG_PATIENT_NAME, "0", true); // Binary value
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
256 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
257 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
258 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
259 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
260 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
261 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
262
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
263 ASSERT_FALSE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
264 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, true));
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
265 ASSERT_EQ("0", s);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
266
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
267
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
268 // 2**31-1
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
269 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483647", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
270 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
271 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
272 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
273 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
274 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
275 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
276 ASSERT_FLOAT_EQ(2147483647.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
277 ASSERT_DOUBLE_EQ(2147483647.0, d);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
278 ASSERT_EQ(2147483647, i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
279 ASSERT_EQ(2147483647ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
280 ASSERT_EQ(2147483647u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
281 ASSERT_EQ(2147483647ull, l);
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
282
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
283 // Test shortcuts
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
284 m.SetValue(DICOM_TAG_PATIENT_NAME, "42", false);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
285 ASSERT_TRUE(m.ParseFloat(f, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
286 ASSERT_TRUE(m.ParseDouble(d, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
287 ASSERT_TRUE(m.ParseInteger32(i, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
288 ASSERT_TRUE(m.ParseInteger64(j, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
289 ASSERT_TRUE(m.ParseUnsignedInteger32(k, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
290 ASSERT_TRUE(m.ParseUnsignedInteger64(l, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
291 ASSERT_FLOAT_EQ(42.0f, f);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
292 ASSERT_DOUBLE_EQ(42.0, d);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
293 ASSERT_EQ(42, i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
294 ASSERT_EQ(42ll, j);
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
295 ASSERT_EQ(42u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
296 ASSERT_EQ(42ull, l);
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
297
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
298 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
299 ASSERT_EQ("42", s);
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
300 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, true));
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
301 ASSERT_EQ("42", s);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
302
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
303
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
304 // 2**31
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
305 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483648", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
306 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
307 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
308 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
309 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
310 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
311 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
312 ASSERT_FLOAT_EQ(2147483648.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
313 ASSERT_DOUBLE_EQ(2147483648.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
314 ASSERT_EQ(2147483648ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
315 ASSERT_EQ(2147483648u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
316 ASSERT_EQ(2147483648ull, l);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
317
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
318 // 2**32-1
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
319 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967295", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
320 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
321 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
322 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
323 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
324 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
325 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
326 ASSERT_FLOAT_EQ(4294967295.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
327 ASSERT_DOUBLE_EQ(4294967295.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
328 ASSERT_EQ(4294967295ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
329 ASSERT_EQ(4294967295u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
330 ASSERT_EQ(4294967295ull, l);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
331
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
332 // 2**32
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
333 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967296", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
334 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
335 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
336 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
337 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
338 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
339 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
340 ASSERT_FLOAT_EQ(4294967296.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
341 ASSERT_DOUBLE_EQ(4294967296.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
342 ASSERT_EQ(4294967296ll, j);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
343 ASSERT_EQ(4294967296ull, l);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
344
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
345 m.SetValue(DICOM_TAG_PATIENT_NAME, "-1", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
346 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
347 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
348 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
349 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
350 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
351 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
352 ASSERT_FLOAT_EQ(-1.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
353 ASSERT_DOUBLE_EQ(-1.0, d);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
354 ASSERT_EQ(-1, i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
355 ASSERT_EQ(-1ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
356
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
357 // -2**31
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
358 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483648", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
359 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
360 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
361 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
362 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
363 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
364 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
365 ASSERT_FLOAT_EQ(-2147483648.0f, f);
2829
61fdb06e389a fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
366 ASSERT_DOUBLE_EQ(-2147483648.0, d);
61fdb06e389a fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
367 ASSERT_EQ(static_cast<int32_t>(-2147483648ll), i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
368 ASSERT_EQ(-2147483648ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
369
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
370 // -2**31 - 1
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
371 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483649", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
372 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseFloat(f));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
373 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseDouble(d));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
374 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger32(i));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
375 ASSERT_TRUE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseInteger64(j));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
376 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger32(k));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
377 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).ParseUnsignedInteger64(l));
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
378 ASSERT_FLOAT_EQ(-2147483649.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
379 ASSERT_DOUBLE_EQ(-2147483649.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
380 ASSERT_EQ(-2147483649ll, j);
3519
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
381
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
382
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
383 // "800\0" in US COLMUNS tag
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
384 m.SetValue(DICOM_TAG_COLUMNS, "800\0", false);
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
385 ASSERT_TRUE(m.GetValue(DICOM_TAG_COLUMNS).ParseFirstUnsignedInteger(ui));
3541
4beabcea3a5c Orthanc-1.5.8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3520
diff changeset
386 ASSERT_EQ(800u, ui);
3519
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
387 m.SetValue(DICOM_TAG_COLUMNS, "800", false);
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3497
diff changeset
388 ASSERT_TRUE(m.GetValue(DICOM_TAG_COLUMNS).ParseFirstUnsignedInteger(ui));
3541
4beabcea3a5c Orthanc-1.5.8
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3520
diff changeset
389 ASSERT_EQ(800u, ui);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
390 }
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
391
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
392
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
393 TEST(DicomMap, Serialize)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
394 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
395 Json::Value s;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
396
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
397 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
398 DicomMap m;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
399 m.SetValue(DICOM_TAG_PATIENT_NAME, "Hello", false);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
400 m.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "Binary", true);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
401 m.SetNullValue(DICOM_TAG_SERIES_DESCRIPTION);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
402 m.Serialize(s);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
403 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
404
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
405 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
406 DicomMap m;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
407 m.Unserialize(s);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
408
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
409 const DicomValue* v = m.TestAndGetValue(DICOM_TAG_ACCESSION_NUMBER);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
410 ASSERT_TRUE(v == NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
411
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
412 v = m.TestAndGetValue(DICOM_TAG_PATIENT_NAME);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
413 ASSERT_TRUE(v != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
414 ASSERT_FALSE(v->IsNull());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
415 ASSERT_FALSE(v->IsBinary());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
416 ASSERT_EQ("Hello", v->GetContent());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
417
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
418 v = m.TestAndGetValue(DICOM_TAG_STUDY_DESCRIPTION);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
419 ASSERT_TRUE(v != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
420 ASSERT_FALSE(v->IsNull());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
421 ASSERT_TRUE(v->IsBinary());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
422 ASSERT_EQ("Binary", v->GetContent());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
423
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
424 v = m.TestAndGetValue(DICOM_TAG_SERIES_DESCRIPTION);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
425 ASSERT_TRUE(v != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
426 ASSERT_TRUE(v->IsNull());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
427 ASSERT_FALSE(v->IsBinary());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
428 ASSERT_THROW(v->GetContent(), OrthancException);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
429 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
430 }
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
431
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
432
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
433
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
434 TEST(DicomMap, ExtractMainDicomTags)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
435 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
436 DicomMap b;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
437 b.SetValue(DICOM_TAG_PATIENT_NAME, "E", false);
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
438 ASSERT_TRUE(b.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
439
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
440 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
441 DicomMap a;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
442 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
443 a.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "B", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
444 a.SetValue(DICOM_TAG_SERIES_DESCRIPTION, "C", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
445 a.SetValue(DICOM_TAG_NUMBER_OF_FRAMES, "D", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
446 a.SetValue(DICOM_TAG_SLICE_THICKNESS, "F", false);
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
447 ASSERT_FALSE(a.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
448 b.ExtractMainDicomTags(a);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
449 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
450
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
451 ASSERT_EQ(4u, b.GetSize());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
452 ASSERT_EQ("A", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
453 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
454 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
455 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
456 ASSERT_FALSE(b.HasTag(DICOM_TAG_SLICE_THICKNESS));
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
457 ASSERT_TRUE(b.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
458
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
459 b.SetValue(DICOM_TAG_PATIENT_NAME, "G", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
460
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
461 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
462 DicomMap a;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
463 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
464 a.SetValue(DICOM_TAG_SLICE_THICKNESS, "F", false);
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
465 ASSERT_FALSE(a.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
466 b.Merge(a);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
467 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
468
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
469 ASSERT_EQ(5u, b.GetSize());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
470 ASSERT_EQ("G", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
471 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
472 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
473 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
474 ASSERT_EQ("F", b.GetValue(DICOM_TAG_SLICE_THICKNESS).GetContent());
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3006
diff changeset
475 ASSERT_FALSE(b.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
476 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
477
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
478
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
479 TEST(DicomMap, RemoveBinary)
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
480 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
481 DicomMap b;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
482 b.SetValue(DICOM_TAG_PATIENT_NAME, "A", false);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
483 b.SetValue(DICOM_TAG_PATIENT_ID, "B", true);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
484 b.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, DicomValue()); // NULL
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
485 b.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, DicomValue("C", false));
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
486 b.SetValue(DICOM_TAG_SOP_INSTANCE_UID, DicomValue("D", true));
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
487
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
488 b.RemoveBinaryTags();
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
489
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
490 std::string s;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
491 ASSERT_EQ(2u, b.GetSize());
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
492 ASSERT_TRUE(b.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false)); ASSERT_EQ("A", s);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
493 ASSERT_TRUE(b.LookupStringValue(s, DICOM_TAG_SERIES_INSTANCE_UID, false)); ASSERT_EQ("C", s);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
494 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
495
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
496
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
497
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
498 TEST(DicomWebJson, Multiplicity)
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
499 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
500 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.4.html
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
501
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
502 ParsedDicomFile dicom(false);
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
503 dicom.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "SB1^SB2^SB3^SB4^SB5");
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
504 dicom.ReplacePlainString(DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "1\\2.3\\4");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
505 dicom.ReplacePlainString(DICOM_TAG_IMAGE_POSITION_PATIENT, "");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
506
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
507 DicomWebJsonVisitor visitor;
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
508 dicom.Apply(visitor);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
509
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
510 {
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
511 const Json::Value& tag = visitor.GetResult() ["00200037"]; // ImageOrientationPatient
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
512 const Json::Value& value = tag["Value"];
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
513
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
514 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
515 ASSERT_EQ(2u, tag.getMemberNames().size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
516 ASSERT_EQ(3u, value.size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
517 ASSERT_EQ(Json::realValue, value[1].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
518 ASSERT_FLOAT_EQ(1.0f, value[0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
519 ASSERT_FLOAT_EQ(2.3f, value[1].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
520 ASSERT_FLOAT_EQ(4.0f, value[2].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
521 }
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
522
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
523 {
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
524 const Json::Value& tag = visitor.GetResult() ["00200032"]; // ImagePositionPatient
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
525 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
526 ASSERT_EQ(1u, tag.getMemberNames().size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
527 }
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
528
3203
810772486249 URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3202
diff changeset
529 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
530 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
531
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
532 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
533 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
534 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
535 ASSERT_EQ(3u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
536
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
537 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
538 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
539 ASSERT_EQ("SB1^SB2^SB3^SB4^SB5", s);
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
540 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_IMAGE_POSITION_PATIENT, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
541 ASSERT_TRUE(s.empty());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
542
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
543 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
544
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
545 std::vector<std::string> v;
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
546 Toolbox::TokenizeString(v, s, '\\');
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
547 ASSERT_FLOAT_EQ(1.0f, boost::lexical_cast<float>(v[0]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
548 ASSERT_FLOAT_EQ(2.3f, boost::lexical_cast<float>(v[1]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
549 ASSERT_FLOAT_EQ(4.0f, boost::lexical_cast<float>(v[2]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
550 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
551 }
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
552
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
553
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
554 TEST(DicomWebJson, NullValue)
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
555 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
556 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.5.html
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
557
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
558 ParsedDicomFile dicom(false);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
559 dicom.ReplacePlainString(DICOM_TAG_IMAGE_ORIENTATION_PATIENT, "1.5\\\\\\2.5");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
560
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
561 DicomWebJsonVisitor visitor;
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
562 dicom.Apply(visitor);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
563
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
564 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
565 const Json::Value& tag = visitor.GetResult() ["00200037"];
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
566 const Json::Value& value = tag["Value"];
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
567
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
568 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
569 ASSERT_EQ(2u, tag.getMemberNames().size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
570 ASSERT_EQ(4u, value.size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
571 ASSERT_EQ(Json::realValue, value[0].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
572 ASSERT_EQ(Json::nullValue, value[1].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
573 ASSERT_EQ(Json::nullValue, value[2].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
574 ASSERT_EQ(Json::realValue, value[3].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
575 ASSERT_FLOAT_EQ(1.5f, value[0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
576 ASSERT_FLOAT_EQ(2.5f, value[3].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
577 }
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
578
3203
810772486249 URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3202
diff changeset
579 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
580 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
581
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
582 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
583 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
584 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
585 ASSERT_EQ(1u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
586
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
587 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
588 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_IMAGE_ORIENTATION_PATIENT, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
589
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
590 std::vector<std::string> v;
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
591 Toolbox::TokenizeString(v, s, '\\');
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
592 ASSERT_FLOAT_EQ(1.5f, boost::lexical_cast<float>(v[0]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
593 ASSERT_TRUE(v[1].empty());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
594 ASSERT_TRUE(v[2].empty());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
595 ASSERT_FLOAT_EQ(2.5f, boost::lexical_cast<float>(v[3]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
596 }
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
597 }
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
598
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
599
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
600 static void SetTagKey(ParsedDicomFile& dicom,
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
601 const DicomTag& tag,
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
602 const DicomTag& value)
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
603 {
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
604 // This function emulates a call to function
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
605 // "dicom.GetDcmtkObject().getDataset()->putAndInsertTagKey(tag,
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
606 // value)" that was not available in DCMTK 3.6.0
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
607
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
608 std::unique_ptr<DcmAttributeTag> element(new DcmAttributeTag(ToDcmtkBridge::Convert(tag)));
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
609
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
610 DcmTagKey v = ToDcmtkBridge::Convert(value);
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
611 if (!element->putTagVal(v).good())
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
612 {
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
613 throw OrthancException(ErrorCode_InternalError);
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
614 }
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
615
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
616 dicom.GetDcmtkObject().getDataset()->insert(element.release());
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
617 }
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
618
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
619
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
620 TEST(DicomWebJson, ValueRepresentation)
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
621 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
622 // http://dicom.nema.org/medical/dicom/current/output/chtml/part18/sect_F.2.3.html
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
623
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
624 ParsedDicomFile dicom(false);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
625 dicom.ReplacePlainString(DicomTag(0x0040, 0x0241), "AE");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
626 dicom.ReplacePlainString(DicomTag(0x0010, 0x1010), "AS");
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
627 SetTagKey(dicom, DicomTag(0x0020, 0x9165), DicomTag(0x0010, 0x0020));
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
628 dicom.ReplacePlainString(DicomTag(0x0008, 0x0052), "CS");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
629 dicom.ReplacePlainString(DicomTag(0x0008, 0x0012), "DA");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
630 dicom.ReplacePlainString(DicomTag(0x0010, 0x1020), "42"); // DS
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
631 dicom.ReplacePlainString(DicomTag(0x0008, 0x002a), "DT");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
632 dicom.ReplacePlainString(DicomTag(0x0010, 0x9431), "43"); // FL
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
633 dicom.ReplacePlainString(DicomTag(0x0008, 0x1163), "44"); // FD
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
634 dicom.ReplacePlainString(DicomTag(0x0008, 0x1160), "45"); // IS
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
635 dicom.ReplacePlainString(DicomTag(0x0008, 0x0070), "LO");
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
636 dicom.ReplacePlainString(DicomTag(0x0010, 0x4000), "LT");
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
637 dicom.ReplacePlainString(DicomTag(0x0028, 0x2000), "OB");
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
638 dicom.ReplacePlainString(DicomTag(0x7fe0, 0x0009), "3.14159"); // OD (other double)
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
639 dicom.ReplacePlainString(DicomTag(0x0064, 0x0009), "2.71828"); // OF (other float)
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
640 dicom.ReplacePlainString(DicomTag(0x0066, 0x0040), "46"); // OL (other long)
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
641 ASSERT_THROW(dicom.ReplacePlainString(DicomTag(0x0028, 0x1201), "O"), OrthancException);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
642 dicom.ReplacePlainString(DicomTag(0x0028, 0x1201), "OWOW");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
643 dicom.ReplacePlainString(DicomTag(0x0010, 0x0010), "PN");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
644 dicom.ReplacePlainString(DicomTag(0x0008, 0x0050), "SH");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
645 dicom.ReplacePlainString(DicomTag(0x0018, 0x6020), "-15"); // SL
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
646 dicom.ReplacePlainString(DicomTag(0x0018, 0x9219), "-16"); // SS
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
647 dicom.ReplacePlainString(DicomTag(0x0008, 0x0081), "ST");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
648 dicom.ReplacePlainString(DicomTag(0x0008, 0x0013), "TM");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
649 dicom.ReplacePlainString(DicomTag(0x0008, 0x0119), "UC");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
650 dicom.ReplacePlainString(DicomTag(0x0008, 0x0016), "UI");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
651 dicom.ReplacePlainString(DicomTag(0x0008, 0x1161), "128"); // UL
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
652 dicom.ReplacePlainString(DicomTag(0x4342, 0x1234), "UN"); // Inexistent tag
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
653 dicom.ReplacePlainString(DicomTag(0x0008, 0x0120), "UR");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
654 dicom.ReplacePlainString(DicomTag(0x0008, 0x0301), "17"); // US
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
655 dicom.ReplacePlainString(DicomTag(0x0040, 0x0031), "UT");
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
656
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
657 DicomWebJsonVisitor visitor;
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
658 dicom.Apply(visitor);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
659
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
660 std::string s;
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
661
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
662 // The tag (0002,0002) is "Media Storage SOP Class UID" and is
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
663 // automatically copied by DCMTK from tag (0008,0016)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
664 ASSERT_EQ("UI", visitor.GetResult() ["00020002"]["vr"].asString());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
665 ASSERT_EQ("UI", visitor.GetResult() ["00020002"]["Value"][0].asString());
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
666 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
667 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
668 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
669 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
670 ASSERT_EQ("AT", visitor.GetResult() ["00209165"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
671 ASSERT_EQ("00100020", visitor.GetResult() ["00209165"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
672 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
673 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
674 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
675 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
676 ASSERT_EQ("DS", visitor.GetResult() ["00101020"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
677 ASSERT_FLOAT_EQ(42.0f, visitor.GetResult() ["00101020"]["Value"][0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
678 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
679 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
680 ASSERT_EQ("FL", visitor.GetResult() ["00109431"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
681 ASSERT_FLOAT_EQ(43.0f, visitor.GetResult() ["00109431"]["Value"][0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
682 ASSERT_EQ("FD", visitor.GetResult() ["00081163"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
683 ASSERT_FLOAT_EQ(44.0f, visitor.GetResult() ["00081163"]["Value"][0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
684 ASSERT_EQ("IS", visitor.GetResult() ["00081160"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
685 ASSERT_FLOAT_EQ(45.0f, visitor.GetResult() ["00081160"]["Value"][0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
686 ASSERT_EQ("LO", visitor.GetResult() ["00080070"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
687 ASSERT_EQ("LO", visitor.GetResult() ["00080070"]["Value"][0].asString());
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
688 ASSERT_EQ("LT", visitor.GetResult() ["00104000"]["vr"].asString());
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
689 ASSERT_EQ("LT", visitor.GetResult() ["00104000"]["Value"][0].asString());
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
690
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
691 ASSERT_EQ("OB", visitor.GetResult() ["00282000"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
692 Toolbox::DecodeBase64(s, visitor.GetResult() ["00282000"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
693 ASSERT_EQ("OB", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
694
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
695 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
696 ASSERT_EQ("OD", visitor.GetResult() ["7FE00009"]["vr"].asString());
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
697 ASSERT_FLOAT_EQ(3.14159f, boost::lexical_cast<float>(visitor.GetResult() ["7FE00009"]["Value"][0].asString()));
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
698 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
699 ASSERT_EQ("UN", visitor.GetResult() ["7FE00009"]["vr"].asString());
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
700 Toolbox::DecodeBase64(s, visitor.GetResult() ["7FE00009"]["InlineBinary"].asString());
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
701 ASSERT_EQ(8u, s.size()); // Because of padding
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
702 ASSERT_EQ(0, s[7]);
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
703 ASSERT_EQ("3.14159", s.substr(0, 7));
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
704 #endif
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
705
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
706 ASSERT_EQ("OF", visitor.GetResult() ["00640009"]["vr"].asString());
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
707 ASSERT_FLOAT_EQ(2.71828f, boost::lexical_cast<float>(visitor.GetResult() ["00640009"]["Value"][0].asString()));
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
708
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
709 #if DCMTK_VERSION_NUMBER < 361
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
710 ASSERT_EQ("UN", visitor.GetResult() ["00660040"]["vr"].asString());
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
711 Toolbox::DecodeBase64(s, visitor.GetResult() ["00660040"]["InlineBinary"].asString());
3211
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3210
diff changeset
712 ASSERT_EQ("46", s);
3694
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3693
diff changeset
713 #elif DCMTK_VERSION_NUMBER == 361
3693
7f0caf198641 fix dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
714 ASSERT_EQ("UL", visitor.GetResult() ["00660040"]["vr"].asString());
7f0caf198641 fix dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
715 ASSERT_EQ(46, visitor.GetResult() ["00660040"]["Value"][0].asInt());
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
716 #else
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
717 ASSERT_EQ("OL", visitor.GetResult() ["00660040"]["vr"].asString());
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
718 ASSERT_EQ(46, visitor.GetResult() ["00660040"]["Value"][0].asInt());
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
719 #endif
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
720
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
721 ASSERT_EQ("OW", visitor.GetResult() ["00281201"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
722 Toolbox::DecodeBase64(s, visitor.GetResult() ["00281201"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
723 ASSERT_EQ("OWOW", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
724
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
725 ASSERT_EQ("PN", visitor.GetResult() ["00100010"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
726 ASSERT_EQ("PN", visitor.GetResult() ["00100010"]["Value"][0]["Alphabetic"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
727
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
728 ASSERT_EQ("SH", visitor.GetResult() ["00080050"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
729 ASSERT_EQ("SH", visitor.GetResult() ["00080050"]["Value"][0].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
730
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
731 ASSERT_EQ("SL", visitor.GetResult() ["00186020"]["vr"].asString());
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
732 ASSERT_EQ(-15, visitor.GetResult() ["00186020"]["Value"][0].asInt());
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
733
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
734 ASSERT_EQ("SS", visitor.GetResult() ["00189219"]["vr"].asString());
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
735 ASSERT_EQ(-16, visitor.GetResult() ["00189219"]["Value"][0].asInt());
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
736
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
737 ASSERT_EQ("ST", visitor.GetResult() ["00080081"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
738 ASSERT_EQ("ST", visitor.GetResult() ["00080081"]["Value"][0].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
739
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
740 ASSERT_EQ("TM", visitor.GetResult() ["00080013"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
741 ASSERT_EQ("TM", visitor.GetResult() ["00080013"]["Value"][0].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
742
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
743 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
744 ASSERT_EQ("UC", visitor.GetResult() ["00080119"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
745 ASSERT_EQ("UC", visitor.GetResult() ["00080119"]["Value"][0].asString());
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
746 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
747 ASSERT_EQ("UN", visitor.GetResult() ["00080119"]["vr"].asString());
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
748 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080119"]["InlineBinary"].asString());
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
749 ASSERT_EQ("UC", s);
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
750 #endif
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
751
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
752 ASSERT_EQ("UI", visitor.GetResult() ["00080016"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
753 ASSERT_EQ("UI", visitor.GetResult() ["00080016"]["Value"][0].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
754
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
755 ASSERT_EQ("UL", visitor.GetResult() ["00081161"]["vr"].asString());
3212
304184684107 Orthanc-1.5.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3211
diff changeset
756 ASSERT_EQ(128u, visitor.GetResult() ["00081161"]["Value"][0].asUInt());
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
757
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
758 ASSERT_EQ("UN", visitor.GetResult() ["43421234"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
759 Toolbox::DecodeBase64(s, visitor.GetResult() ["43421234"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
760 ASSERT_EQ("UN", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
761
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
762 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
763 ASSERT_EQ("UR", visitor.GetResult() ["00080120"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
764 ASSERT_EQ("UR", visitor.GetResult() ["00080120"]["Value"][0].asString());
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
765 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
766 ASSERT_EQ("UN", visitor.GetResult() ["00080120"]["vr"].asString());
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
767 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080120"]["InlineBinary"].asString());
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
768 ASSERT_EQ("UR", s);
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
769 #endif
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
770
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
771 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
772 ASSERT_EQ("US", visitor.GetResult() ["00080301"]["vr"].asString());
3212
304184684107 Orthanc-1.5.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3211
diff changeset
773 ASSERT_EQ(17u, visitor.GetResult() ["00080301"]["Value"][0].asUInt());
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
774 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
775 ASSERT_EQ("UN", visitor.GetResult() ["00080301"]["vr"].asString());
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
776 Toolbox::DecodeBase64(s, visitor.GetResult() ["00080301"]["InlineBinary"].asString());
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
777 ASSERT_EQ("17", s);
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
778 #endif
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
779
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
780 ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
781 ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["Value"][0].asString());
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
782
3203
810772486249 URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3202
diff changeset
783 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
784 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
785
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
786 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
787 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
788 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
789 ASSERT_EQ(31u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
790
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
791 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
792 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0002, 0x0002), false)); ASSERT_EQ("UI", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
793 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0040, 0x0241), false)); ASSERT_EQ("AE", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
794 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x1010), false)); ASSERT_EQ("AS", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
795 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0020, 0x9165), false)); ASSERT_EQ("00100020", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
796 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0052), false)); ASSERT_EQ("CS", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
797 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0012), false)); ASSERT_EQ("DA", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
798 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x1020), false)); ASSERT_EQ("42", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
799 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x002a), false)); ASSERT_EQ("DT", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
800 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x9431), false)); ASSERT_EQ("43", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
801 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x1163), false)); ASSERT_EQ("44", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
802 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x1160), false)); ASSERT_EQ("45", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
803 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0070), false)); ASSERT_EQ("LO", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
804 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x4000), false)); ASSERT_EQ("LT", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
805 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0028, 0x2000), true)); ASSERT_EQ("OB", s);
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
806 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x7fe0, 0x0009), true));
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
807
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
808 #if DCMTK_VERSION_NUMBER >= 361
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
809 ASSERT_FLOAT_EQ(3.14159f, boost::lexical_cast<float>(s));
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
810 #else
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
811 ASSERT_EQ(8u, s.size()); // Because of padding
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
812 ASSERT_EQ(0, s[7]);
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
813 ASSERT_EQ("3.14159", s.substr(0, 7));
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
814 #endif
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
815
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
816 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0064, 0x0009), true));
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
817 ASSERT_FLOAT_EQ(2.71828f, boost::lexical_cast<float>(s));
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
818 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0028, 0x1201), true)); ASSERT_EQ("OWOW", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
819 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0010, 0x0010), false)); ASSERT_EQ("PN", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
820 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0050), false)); ASSERT_EQ("SH", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
821 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0018, 0x6020), false)); ASSERT_EQ("-15", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
822 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0018, 0x9219), false)); ASSERT_EQ("-16", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
823 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0081), false)); ASSERT_EQ("ST", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
824 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0013), false)); ASSERT_EQ("TM", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
825 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0016), false)); ASSERT_EQ("UI", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
826 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x1161), false)); ASSERT_EQ("128", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
827 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x4342, 0x1234), true)); ASSERT_EQ("UN", s);
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
828 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0040, 0x0031), false)); ASSERT_EQ("UT", s);
3497
db71bd11affc fix unit tests if dcmtk != 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
829
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
830 #if DCMTK_VERSION_NUMBER >= 361
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
831 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0066, 0x0040), false)); ASSERT_EQ("46", s);
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
832 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0119), false)); ASSERT_EQ("UC", s);
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
833 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0120), false)); ASSERT_EQ("UR", s);
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
834 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0301), false)); ASSERT_EQ("17", s);
3497
db71bd11affc fix unit tests if dcmtk != 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
835 #else
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
836 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0066, 0x0040), true)); ASSERT_EQ("46", s); // OL
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
837 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0119), true)); ASSERT_EQ("UC", s);
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
838 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0120), true)); ASSERT_EQ("UR", s);
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
839 ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x0008, 0x0301), true)); ASSERT_EQ("17", s); // US (but tag unknown to DCMTK 3.6.0)
3497
db71bd11affc fix unit tests if dcmtk != 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3496
diff changeset
840 #endif
3691
4922bdd046dd Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3651
diff changeset
841
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
842 }
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
843 }
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
844
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
845
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
846 TEST(DicomWebJson, Sequence)
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
847 {
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
848 ParsedDicomFile dicom(false);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
849
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
850 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
851 std::unique_ptr<DcmSequenceOfItems> sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence));
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
852
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
853 for (unsigned int i = 0; i < 3; i++)
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
854 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
855 std::unique_ptr<DcmItem> item(new DcmItem);
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
856 std::string s = "item" + boost::lexical_cast<std::string>(i);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
857 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, s.c_str(), OFFalse);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
858 ASSERT_TRUE(sequence->insert(item.release(), false, false).good());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
859 }
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
860
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
861 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->insert(sequence.release(), false, false).good());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
862 }
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
863
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
864 DicomWebJsonVisitor visitor;
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
865 dicom.Apply(visitor);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
866
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
867 ASSERT_EQ("SQ", visitor.GetResult() ["00081115"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
868 ASSERT_EQ(3u, visitor.GetResult() ["00081115"]["Value"].size());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
869
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
870 std::set<std::string> items;
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
871
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
872 for (Json::Value::ArrayIndex i = 0; i < 3; i++)
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
873 {
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
874 ASSERT_EQ(1u, visitor.GetResult() ["00081115"]["Value"][i].size());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
875 ASSERT_EQ(1u, visitor.GetResult() ["00081115"]["Value"][i]["00081155"]["Value"].size());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
876 ASSERT_EQ("UI", visitor.GetResult() ["00081115"]["Value"][i]["00081155"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
877 items.insert(visitor.GetResult() ["00081115"]["Value"][i]["00081155"]["Value"][0].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
878 }
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
879
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
880 ASSERT_EQ(3u, items.size());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
881 ASSERT_TRUE(items.find("item0") != items.end());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
882 ASSERT_TRUE(items.find("item1") != items.end());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
883 ASSERT_TRUE(items.find("item2") != items.end());
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
884
3203
810772486249 URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3202
diff changeset
885 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
886 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
887
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
888 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
889 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
890 m.FromDicomWeb(visitor.GetResult());
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
891 ASSERT_EQ(0u, m.GetSize()); // Sequences are not handled by DicomMap
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
892 }
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
893 }
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
894
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
895
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
896 TEST(DicomWebJson, PixelSpacing)
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
897 {
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
898 // Test related to locales: Make sure that decimal separator is
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
899 // correctly handled (dot "." vs comma ",")
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
900 ParsedDicomFile source(false);
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
901 source.ReplacePlainString(DICOM_TAG_PIXEL_SPACING, "1.5\\1.3");
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
902
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
903 DicomWebJsonVisitor visitor;
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
904 source.Apply(visitor);
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
905
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
906 DicomMap target;
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
907 target.FromDicomWeb(visitor.GetResult());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
908
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
909 ASSERT_EQ("DS", visitor.GetResult() ["00280030"]["vr"].asString());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
910 ASSERT_FLOAT_EQ(1.5f, visitor.GetResult() ["00280030"]["Value"][0].asFloat());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
911 ASSERT_FLOAT_EQ(1.3f, visitor.GetResult() ["00280030"]["Value"][1].asFloat());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
912
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
913 std::string s;
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
914 ASSERT_TRUE(target.LookupStringValue(s, DICOM_TAG_PIXEL_SPACING, false));
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
915 ASSERT_EQ(s, "1.5\\1.3");
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
916 }
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
917
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
918
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
919 TEST(DicomMap, MainTagNames)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
920 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
921 ASSERT_EQ(3, ResourceType_Instance - ResourceType_Patient);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
922
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
923 for (int i = ResourceType_Patient; i <= ResourceType_Instance; i++)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
924 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
925 ResourceType level = static_cast<ResourceType>(i);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
926
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
927 std::set<DicomTag> tags;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
928 DicomMap::GetMainDicomTags(tags, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
929
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
930 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
931 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
932 DicomMap a;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
933 a.SetValue(*it, "TEST", false);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
934
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
935 Json::Value json;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
936 a.DumpMainDicomTags(json, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
937
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
938 ASSERT_EQ(Json::objectValue, json.type());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
939 ASSERT_EQ(1u, json.getMemberNames().size());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
940
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
941 std::string name = json.getMemberNames() [0];
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
942 EXPECT_EQ(name, FromDcmtkBridge::GetTagName(*it, ""));
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
943
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
944 DicomMap b;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
945 b.ParseMainDicomTags(json, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
946
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
947 ASSERT_EQ(1u, b.GetSize());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
948 ASSERT_EQ("TEST", b.GetStringValue(*it, "", false));
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
949
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
950 std::string main = it->GetMainTagsName();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
951 if (!main.empty())
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
952 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
953 ASSERT_EQ(main, name);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
954 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
955 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
956 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
957 }