annotate UnitTestsSources/DicomMapTests.cpp @ 3754:ef625518c27c storage-commitment

closing branch storage-commitment
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Mar 2020 12:15:52 +0100
parents 2a170a8f1faf
children
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
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 827
diff changeset
34 #include "PrecompiledHeadersUnitTests.h"
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "gtest/gtest.h"
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
37 #include "../Core/Compatibility.h"
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../Core/OrthancException.h"
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include "../Core/DicomFormat/DicomMap.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
40 #include "../Core/DicomParsing/FromDcmtkBridge.h"
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
41 #include "../Core/DicomParsing/ToDcmtkBridge.h"
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
42 #include "../Core/DicomParsing/ParsedDicomFile.h"
3202
ef4d86d05503 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3201
diff changeset
43 #include "../Core/DicomParsing/DicomWebJsonVisitor.h"
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
44
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
45 #include "../OrthancServer/DicomInstanceToStore.h"
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 #include <memory>
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
48 #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
49 #include <dcmtk/dcmdata/dcvrat.h>
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 using namespace Orthanc;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 TEST(DicomMap, MainTags)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Patient));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 ASSERT_FALSE(DicomMap::IsMainDicomTag(DICOM_TAG_PATIENT_ID, ResourceType_Study));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 ASSERT_TRUE(DicomMap::IsMainDicomTag(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 std::set<DicomTag> s;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 DicomMap::GetMainDicomTags(s);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 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
70 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
71
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 DicomMap::GetMainDicomTags(s, ResourceType_Patient);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 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
75
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 DicomMap::GetMainDicomTags(s, ResourceType_Study);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 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
78 ASSERT_TRUE(s.end() != s.find(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 DicomMap::GetMainDicomTags(s, ResourceType_Series);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 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
83 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 DicomMap::GetMainDicomTags(s, ResourceType_Instance);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 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
87 ASSERT_TRUE(s.end() == s.find(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
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 TEST(DicomMap, Tags)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 {
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
93 std::set<DicomTag> s;
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
94
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 DicomMap m;
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
96 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
97 ASSERT_EQ(0u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
98
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_NAME));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 ASSERT_FALSE(m.HasTag(0x0010, 0x0010));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
101 m.SetValue(0x0010, 0x0010, "PatientName", false);
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_NAME));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 ASSERT_TRUE(m.HasTag(0x0010, 0x0010));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
105 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
106 ASSERT_EQ(1u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
107 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin());
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
108
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 ASSERT_FALSE(m.HasTag(DICOM_TAG_PATIENT_ID));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
110 m.SetValue(DICOM_TAG_PATIENT_ID, "PatientID", false);
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 ASSERT_TRUE(m.HasTag(0x0010, 0x0020));
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
112 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
113 ASSERT_EQ("PatientID2", m.GetValue(0x0010, 0x0020).GetContent());
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
115 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
116 ASSERT_EQ(2u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
117
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 m.Remove(DICOM_TAG_PATIENT_ID);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 ASSERT_THROW(m.GetValue(0x0010, 0x0020), OrthancException);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
121 m.GetTags(s);
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1368
diff changeset
122 ASSERT_EQ(1u, s.size());
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
123 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, *s.begin());
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1304
diff changeset
124
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
125 std::unique_ptr<DicomMap> mm(m.Clone());
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
126 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
127
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
128 m.SetValue(DICOM_TAG_PATIENT_ID, "Hello", false);
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 ASSERT_THROW(mm->GetValue(DICOM_TAG_PATIENT_ID), OrthancException);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 mm->CopyTagIfExists(m, DICOM_TAG_PATIENT_ID);
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
131 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
132
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1704
diff changeset
133 DicomValue v;
711
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 ASSERT_TRUE(v.IsNull());
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 }
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 TEST(DicomMap, FindTemplates)
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 DicomMap m;
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 DicomMap::SetupFindPatientTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 ASSERT_TRUE(m.HasTag(DICOM_TAG_PATIENT_ID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 DicomMap::SetupFindStudyTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 ASSERT_TRUE(m.HasTag(DICOM_TAG_STUDY_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 ASSERT_TRUE(m.HasTag(DICOM_TAG_ACCESSION_NUMBER));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 DicomMap::SetupFindSeriesTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 DicomMap::SetupFindInstanceTemplate(m);
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 ASSERT_TRUE(m.HasTag(DICOM_TAG_SOP_INSTANCE_UID));
8f62e8d5a384 test main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
155
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
156
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
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
159 static void TestModule(ResourceType level,
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
160 DicomModule module)
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
161 {
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
162 // REFERENCE: DICOM PS3.3 2015c - Information Object Definitions
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
163 // 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
164
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
165 std::set<DicomTag> moduleTags, main;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
166 DicomTag::AddTagsForModule(moduleTags, module);
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
167 DicomMap::GetMainDicomTags(main, level);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
168
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
169 // The main dicom tags are a subset of the module
1304
7b6925b0890d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
170 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
171 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
172 bool ok = moduleTags.find(*it) != moduleTags.end();
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
173
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
174 // Exceptions for the Study level
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
175 if (level == ResourceType_Study &&
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
176 (*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
177 *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
178 *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
179 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
180 ok = true;
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
181 }
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
182
1849
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
183 // Exceptions for the Series level
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
184 if (level == ResourceType_Series &&
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
185 (*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
186 *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
187 *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
188 *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
189 *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
190 *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
191 *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
192 *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
193 *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
194 *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
195 *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
196 *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
197 {
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
198 ok = true;
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
199 }
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
200
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
201 // Exceptions for the Instance level
1704
d2268c7a7ede fix unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
202 if (level == ResourceType_Instance &&
1848
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
203 (*it == DicomTag(0x0020, 0x0012) || /* AccessionNumber, from General Image module */
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
204 *it == DicomTag(0x0054, 0x1330) || /* ImageIndex, from PET Image module */
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
205 *it == DicomTag(0x0020, 0x0100) || /* TemporalPositionIdentifier, from MR Image module */
e39716f71d67 new main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
206 *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
207 *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
208 *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
209 *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
210 {
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
211 ok = true;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
212 }
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 if (!ok)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
215 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
216 std::cout << it->Format() << ": " << FromDcmtkBridge::GetTagName(*it, "")
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
217 << " not expected at level " << EnumerationToString(level) << std::endl;
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
218 }
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 EXPECT_TRUE(ok);
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
221 }
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 TEST(DicomMap, Modules)
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
226 {
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
227 TestModule(ResourceType_Patient, DicomModule_Patient);
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
228 TestModule(ResourceType_Study, DicomModule_Study);
1849
6394a2f8f1e1 test main dicom tags at series level
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1848
diff changeset
229 TestModule(ResourceType_Series, DicomModule_Series); // TODO
1276
6164f7200c43 refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
230 TestModule(ResourceType_Instance, DicomModule_Instance);
963
81134ea872ff retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
231 }
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
232
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 TEST(DicomMap, Parse)
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
235 {
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
236 DicomMap m;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
237 float f;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
238 double d;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
239 int32_t i;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
240 int64_t j;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
241 uint32_t k;
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
242 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
243 unsigned int ui;
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
244 std::string s;
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
245
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
246 m.SetValue(DICOM_TAG_PATIENT_NAME, " ", false); // Empty value
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
247 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
248 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
249 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
250 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
251 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
252 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
253
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
262 ASSERT_FALSE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
263 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
264 ASSERT_EQ("0", s);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
265
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
266
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
267 // 2**31-1
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
268 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483647", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
269 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
270 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
271 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
272 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
273 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
274 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
275 ASSERT_FLOAT_EQ(2147483647.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
276 ASSERT_DOUBLE_EQ(2147483647.0, d);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
277 ASSERT_EQ(2147483647, i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
278 ASSERT_EQ(2147483647ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
279 ASSERT_EQ(2147483647u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
280 ASSERT_EQ(2147483647ull, l);
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
281
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
282 // Test shortcuts
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
283 m.SetValue(DICOM_TAG_PATIENT_NAME, "42", false);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
284 ASSERT_TRUE(m.ParseFloat(f, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
285 ASSERT_TRUE(m.ParseDouble(d, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
286 ASSERT_TRUE(m.ParseInteger32(i, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
287 ASSERT_TRUE(m.ParseInteger64(j, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
288 ASSERT_TRUE(m.ParseUnsignedInteger32(k, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
289 ASSERT_TRUE(m.ParseUnsignedInteger64(l, DICOM_TAG_PATIENT_NAME));
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
290 ASSERT_FLOAT_EQ(42.0f, f);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
291 ASSERT_DOUBLE_EQ(42.0, d);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
292 ASSERT_EQ(42, i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
293 ASSERT_EQ(42ll, j);
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
294 ASSERT_EQ(42u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
295 ASSERT_EQ(42ull, l);
2412
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
296
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
297 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
298 ASSERT_EQ("42", s);
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
299 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
300 ASSERT_EQ("42", s);
cad393b41bc3 handy shortcuts in DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2410
diff changeset
301
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
302
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
303 // 2**31
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
304 m.SetValue(DICOM_TAG_PATIENT_NAME, "2147483648", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
305 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
306 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
307 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
308 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
309 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
310 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
311 ASSERT_FLOAT_EQ(2147483648.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
312 ASSERT_DOUBLE_EQ(2147483648.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
313 ASSERT_EQ(2147483648ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
314 ASSERT_EQ(2147483648u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
315 ASSERT_EQ(2147483648ull, l);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
316
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
317 // 2**32-1
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
318 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967295", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
319 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
320 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
321 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
322 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
323 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
324 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
325 ASSERT_FLOAT_EQ(4294967295.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
326 ASSERT_DOUBLE_EQ(4294967295.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
327 ASSERT_EQ(4294967295ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
328 ASSERT_EQ(4294967295u, k);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
329 ASSERT_EQ(4294967295ull, l);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
330
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
331 // 2**32
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
332 m.SetValue(DICOM_TAG_PATIENT_NAME, "4294967296", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
333 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
334 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
335 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
336 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
337 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
338 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
339 ASSERT_FLOAT_EQ(4294967296.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
340 ASSERT_DOUBLE_EQ(4294967296.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
341 ASSERT_EQ(4294967296ll, j);
2418
abc275c0a44d fix msvc 2008
jodogne
parents: 2416
diff changeset
342 ASSERT_EQ(4294967296ull, l);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
343
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
344 m.SetValue(DICOM_TAG_PATIENT_NAME, "-1", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
345 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
346 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
347 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
348 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
349 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
350 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
351 ASSERT_FLOAT_EQ(-1.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
352 ASSERT_DOUBLE_EQ(-1.0, d);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
353 ASSERT_EQ(-1, i);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
354 ASSERT_EQ(-1ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
355
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
356 // -2**31
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
357 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483648", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
358 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
359 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
360 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
361 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
362 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
363 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
364 ASSERT_FLOAT_EQ(-2147483648.0f, f);
2829
61fdb06e389a fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
365 ASSERT_DOUBLE_EQ(-2147483648.0, d);
61fdb06e389a fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2804
diff changeset
366 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
367 ASSERT_EQ(-2147483648ll, j);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
368
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
369 // -2**31 - 1
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
370 m.SetValue(DICOM_TAG_PATIENT_NAME, "-2147483649", false);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
371 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
372 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
373 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
374 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
375 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
376 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
377 ASSERT_FLOAT_EQ(-2147483649.0f, f);
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
378 ASSERT_DOUBLE_EQ(-2147483649.0, d);
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2412
diff changeset
379 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
380
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 // "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
383 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
384 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
385 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
386 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
387 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
388 ASSERT_EQ(800u, ui);
2410
3590c936e56f parsing numbers in DicomValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2382
diff changeset
389 }
2863
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
390
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 TEST(DicomMap, Serialize)
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
393 {
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
394 Json::Value s;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
395
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 DicomMap m;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
398 m.SetValue(DICOM_TAG_PATIENT_NAME, "Hello", false);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
399 m.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "Binary", true);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
400 m.SetNullValue(DICOM_TAG_SERIES_DESCRIPTION);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
401 m.Serialize(s);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
402 }
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 DicomMap m;
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
406 m.Unserialize(s);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
407
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
408 const DicomValue* v = m.TestAndGetValue(DICOM_TAG_ACCESSION_NUMBER);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
409 ASSERT_TRUE(v == NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
410
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
411 v = m.TestAndGetValue(DICOM_TAG_PATIENT_NAME);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
412 ASSERT_TRUE(v != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
413 ASSERT_FALSE(v->IsNull());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
414 ASSERT_FALSE(v->IsBinary());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
415 ASSERT_EQ("Hello", v->GetContent());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
416
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
417 v = m.TestAndGetValue(DICOM_TAG_STUDY_DESCRIPTION);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
418 ASSERT_TRUE(v != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
419 ASSERT_FALSE(v->IsNull());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
420 ASSERT_TRUE(v->IsBinary());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
421 ASSERT_EQ("Binary", v->GetContent());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
422
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
423 v = m.TestAndGetValue(DICOM_TAG_SERIES_DESCRIPTION);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
424 ASSERT_TRUE(v != NULL);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
425 ASSERT_TRUE(v->IsNull());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
426 ASSERT_FALSE(v->IsBinary());
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
427 ASSERT_THROW(v->GetContent(), OrthancException);
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
428 }
da12ba232119 serialization of DicomMap
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2829
diff changeset
429 }
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
430
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 TEST(DicomMap, DicomAsJson)
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
434 {
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
435 // This is a Latin-1 test string: "crane" with a circumflex accent
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
436 const unsigned char raw[] = { 0x63, 0x72, 0xe2, 0x6e, 0x65 };
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
437 std::string latin1((char*) &raw[0], sizeof(raw) / sizeof(char));
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
438
3217
cf8cbeb35f33 preliminary support of Korean character set
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3212
diff changeset
439 std::string utf8 = Toolbox::ConvertToUtf8(latin1, Encoding_Latin1, false);
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
440
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
441 ParsedDicomFile dicom(false);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
442 dicom.SetEncoding(Encoding_Latin1);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
443 dicom.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "Hello");
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
444 dicom.ReplacePlainString(DICOM_TAG_STUDY_DESCRIPTION, utf8);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
445 dicom.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, std::string(ORTHANC_MAXIMUM_TAG_LENGTH, 'a'));
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
446 dicom.ReplacePlainString(DICOM_TAG_MANUFACTURER, std::string(ORTHANC_MAXIMUM_TAG_LENGTH + 1, 'a'));
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
447 dicom.ReplacePlainString(DICOM_TAG_PIXEL_DATA, "binary");
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
448 dicom.ReplacePlainString(DICOM_TAG_ROWS, "512");
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
449
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
450 DcmDataset& dataset = *dicom.GetDcmtkObject().getDataset();
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
451 dataset.insertEmptyElement(DCM_StudyID, OFFalse);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
452
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
453 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
454 std::unique_ptr<DcmSequenceOfItems> sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence));
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
455
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
456 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
457 std::unique_ptr<DcmItem> item(new DcmItem);
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
458 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, "nope", OFFalse);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
459 ASSERT_TRUE(sequence->insert(item.release(), false, false).good());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
460 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
461
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
462 ASSERT_TRUE(dataset.insert(sequence.release(), false, false).good());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
463 }
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
464
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
465
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
466 // Check re-encoding
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
467 DcmElement* element = NULL;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
468 ASSERT_TRUE(dataset.findAndGetElement(DCM_StudyDescription, element).good() &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
469 element != NULL);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
470
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
471 char* c = NULL;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
472 ASSERT_TRUE(element != NULL &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
473 element->isLeaf() &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
474 element->isaString() &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
475 element->getString(c).good());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
476 ASSERT_EQ(0, memcmp(c, raw, latin1.length()));
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
477
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
478 ASSERT_TRUE(dataset.findAndGetElement(DCM_Rows, element).good() &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
479 element != NULL &&
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
480 element->getTag().getEVR() == EVR_US);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
481
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
482 DicomInstanceToStore toStore;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
483 toStore.SetParsedDicomFile(dicom);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
484
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
485 DicomMap m;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
486 m.FromDicomAsJson(toStore.GetJson());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
487
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
488 ASSERT_EQ("ISO_IR 100", m.GetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET).GetContent());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
489
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
490 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).IsBinary());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
491 ASSERT_EQ("Hello", m.GetValue(DICOM_TAG_PATIENT_NAME).GetContent());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
492
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
493 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).IsBinary());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
494 ASSERT_EQ(utf8, m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
495
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
496 ASSERT_FALSE(m.HasTag(DICOM_TAG_MANUFACTURER)); // Too long
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
497 ASSERT_FALSE(m.HasTag(DICOM_TAG_PIXEL_DATA)); // Pixel data
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
498 ASSERT_FALSE(m.HasTag(DICOM_TAG_REFERENCED_SERIES_SEQUENCE)); // Sequence
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
499 ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetGroup(), DCM_ReferencedSeriesSequence.getGroup());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
500 ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetElement(), DCM_ReferencedSeriesSequence.getElement());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
501
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
502 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_DESCRIPTION)); // Maximum length
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
503 ASSERT_FALSE(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).IsBinary());
3040
07ab06af90ed preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3015
diff changeset
504 ASSERT_EQ(ORTHANC_MAXIMUM_TAG_LENGTH,
07ab06af90ed preparing for release
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3015
diff changeset
505 static_cast<int>(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent().length()));
3005
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
506
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
507 ASSERT_FALSE(m.GetValue(DICOM_TAG_ROWS).IsBinary());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
508 ASSERT_EQ("512", m.GetValue(DICOM_TAG_ROWS).GetContent());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
509
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
510 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsNull());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
511 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsBinary());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
512 ASSERT_EQ("", m.GetValue(DICOM_TAG_STUDY_ID).GetContent());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
513
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
514 DicomArray a(m);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
515 ASSERT_EQ(6u, a.GetSize());
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
516
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
517
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
518 //dicom.SaveToFile("/tmp/test.dcm");
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
519 //std::cout << toStore.GetJson() << std::endl;
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
520 //a.Print(stdout);
8265a6b56100 DicomMap::FromDicomAsJson
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2863
diff changeset
521 }
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
522
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
523
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
524
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
525 TEST(DicomMap, ExtractMainDicomTags)
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
526 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
527 DicomMap b;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
528 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
529 ASSERT_TRUE(b.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
530
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
531 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
532 DicomMap a;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
533 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
534 a.SetValue(DICOM_TAG_STUDY_DESCRIPTION, "B", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
535 a.SetValue(DICOM_TAG_SERIES_DESCRIPTION, "C", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
536 a.SetValue(DICOM_TAG_NUMBER_OF_FRAMES, "D", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
537 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
538 ASSERT_FALSE(a.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
539 b.ExtractMainDicomTags(a);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
540 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
541
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
542 ASSERT_EQ(4u, b.GetSize());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
543 ASSERT_EQ("A", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
544 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
545 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
546 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
547 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
548 ASSERT_TRUE(b.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
549
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
550 b.SetValue(DICOM_TAG_PATIENT_NAME, "G", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
551
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
552 {
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
553 DicomMap a;
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
554 a.SetValue(DICOM_TAG_PATIENT_NAME, "A", false);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
555 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
556 ASSERT_FALSE(a.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
557 b.Merge(a);
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
558 }
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
559
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
560 ASSERT_EQ(5u, b.GetSize());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
561 ASSERT_EQ("G", b.GetValue(DICOM_TAG_PATIENT_NAME).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
562 ASSERT_EQ("B", b.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
563 ASSERT_EQ("C", b.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
564 ASSERT_EQ("D", b.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent());
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
565 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
566 ASSERT_FALSE(b.HasOnlyMainDicomTags());
3006
0e1755e5efd0 DicomMap::ExtractMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
567 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
568
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
569
3551
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
570 TEST(DicomMap, RemoveBinary)
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
571 {
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
572 DicomMap b;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
573 b.SetValue(DICOM_TAG_PATIENT_NAME, "A", false);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
574 b.SetValue(DICOM_TAG_PATIENT_ID, "B", true);
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
575 b.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, DicomValue()); // NULL
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
576 b.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, DicomValue("C", false));
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
577 b.SetValue(DICOM_TAG_SOP_INSTANCE_UID, DicomValue("D", true));
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
578
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
579 b.RemoveBinaryTags();
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
580
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
581 std::string s;
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
582 ASSERT_EQ(2u, b.GetSize());
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
583 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
584 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
585 }
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
586
173c7f363d8f DicomMap::RemoveBinaryTags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3541
diff changeset
587
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
588
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
589 TEST(DicomWebJson, Multiplicity)
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
590 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
591 // 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
592
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
593 ParsedDicomFile dicom(false);
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
594 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
595 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
596 dicom.ReplacePlainString(DICOM_TAG_IMAGE_POSITION_PATIENT, "");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
597
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
598 DicomWebJsonVisitor visitor;
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
599 dicom.Apply(visitor);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
600
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
601 {
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
602 const Json::Value& tag = visitor.GetResult() ["00200037"]; // ImageOrientationPatient
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
603 const Json::Value& value = tag["Value"];
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
604
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
605 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
606 ASSERT_EQ(2u, tag.getMemberNames().size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
607 ASSERT_EQ(3u, value.size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
608 ASSERT_EQ(Json::realValue, value[1].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
609 ASSERT_FLOAT_EQ(1.0f, value[0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
610 ASSERT_FLOAT_EQ(2.3f, value[1].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
611 ASSERT_FLOAT_EQ(4.0f, value[2].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
612 }
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
613
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
614 {
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
615 const Json::Value& tag = visitor.GetResult() ["00200032"]; // ImagePositionPatient
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
616 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
617 ASSERT_EQ(1u, tag.getMemberNames().size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
618 }
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
619
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
620 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
621 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
622
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
623 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
624 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
625 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
626 ASSERT_EQ(3u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
627
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
628 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
629 ASSERT_TRUE(m.LookupStringValue(s, DICOM_TAG_PATIENT_NAME, false));
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
630 ASSERT_EQ("SB1^SB2^SB3^SB4^SB5", s);
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
631 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
632 ASSERT_TRUE(s.empty());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
633
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
634 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
635
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
636 std::vector<std::string> v;
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
637 Toolbox::TokenizeString(v, s, '\\');
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
638 ASSERT_FLOAT_EQ(1.0f, boost::lexical_cast<float>(v[0]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
639 ASSERT_FLOAT_EQ(2.3f, boost::lexical_cast<float>(v[1]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
640 ASSERT_FLOAT_EQ(4.0f, boost::lexical_cast<float>(v[2]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
641 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
642 }
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
643
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
644
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
645 TEST(DicomWebJson, NullValue)
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
646 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
647 // 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
648
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
649 ParsedDicomFile dicom(false);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
650 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
651
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
652 DicomWebJsonVisitor visitor;
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
653 dicom.Apply(visitor);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
654
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
655 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
656 const Json::Value& tag = visitor.GetResult() ["00200037"];
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
657 const Json::Value& value = tag["Value"];
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
658
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
659 ASSERT_EQ(EnumerationToString(ValueRepresentation_DecimalString), tag["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
660 ASSERT_EQ(2u, tag.getMemberNames().size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
661 ASSERT_EQ(4u, value.size());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
662 ASSERT_EQ(Json::realValue, value[0].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
663 ASSERT_EQ(Json::nullValue, value[1].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
664 ASSERT_EQ(Json::nullValue, value[2].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
665 ASSERT_EQ(Json::realValue, value[3].type());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
666 ASSERT_FLOAT_EQ(1.5f, value[0].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
667 ASSERT_FLOAT_EQ(2.5f, value[3].asFloat());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
668 }
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
669
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
670 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
671 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
672
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
673 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
674 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
675 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
676 ASSERT_EQ(1u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
677
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
678 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
679 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
680
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
681 std::vector<std::string> v;
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
682 Toolbox::TokenizeString(v, s, '\\');
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
683 ASSERT_FLOAT_EQ(1.5f, boost::lexical_cast<float>(v[0]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
684 ASSERT_TRUE(v[1].empty());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
685 ASSERT_TRUE(v[2].empty());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
686 ASSERT_FLOAT_EQ(2.5f, boost::lexical_cast<float>(v[3]));
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
687 }
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
688 }
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
689
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
690
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
691 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
692 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
693 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
694 {
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
695 // 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
696 // "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
697 // 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
698
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
699 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
700
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
701 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
702 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
703 {
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
704 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
705 }
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
706
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
707 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
708 }
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
709
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
710
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
711 TEST(DicomWebJson, ValueRepresentation)
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
712 {
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
713 // 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
714
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
715 ParsedDicomFile dicom(false);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
716 dicom.ReplacePlainString(DicomTag(0x0040, 0x0241), "AE");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
717 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
718 SetTagKey(dicom, DicomTag(0x0020, 0x9165), DicomTag(0x0010, 0x0020));
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
719 dicom.ReplacePlainString(DicomTag(0x0008, 0x0052), "CS");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
720 dicom.ReplacePlainString(DicomTag(0x0008, 0x0012), "DA");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
721 dicom.ReplacePlainString(DicomTag(0x0010, 0x1020), "42"); // DS
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
722 dicom.ReplacePlainString(DicomTag(0x0008, 0x002a), "DT");
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
723 dicom.ReplacePlainString(DicomTag(0x0010, 0x9431), "43"); // FL
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
724 dicom.ReplacePlainString(DicomTag(0x0008, 0x1163), "44"); // FD
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
725 dicom.ReplacePlainString(DicomTag(0x0008, 0x1160), "45"); // IS
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
726 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
727 dicom.ReplacePlainString(DicomTag(0x0010, 0x4000), "LT");
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
728 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
729 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
730 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
731 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
732 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
733 dicom.ReplacePlainString(DicomTag(0x0028, 0x1201), "OWOW");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
734 dicom.ReplacePlainString(DicomTag(0x0010, 0x0010), "PN");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
735 dicom.ReplacePlainString(DicomTag(0x0008, 0x0050), "SH");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
736 dicom.ReplacePlainString(DicomTag(0x0018, 0x6020), "-15"); // SL
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
737 dicom.ReplacePlainString(DicomTag(0x0018, 0x9219), "-16"); // SS
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
738 dicom.ReplacePlainString(DicomTag(0x0008, 0x0081), "ST");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
739 dicom.ReplacePlainString(DicomTag(0x0008, 0x0013), "TM");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
740 dicom.ReplacePlainString(DicomTag(0x0008, 0x0119), "UC");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
741 dicom.ReplacePlainString(DicomTag(0x0008, 0x0016), "UI");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
742 dicom.ReplacePlainString(DicomTag(0x0008, 0x1161), "128"); // UL
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
743 dicom.ReplacePlainString(DicomTag(0x4342, 0x1234), "UN"); // Inexistent tag
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
744 dicom.ReplacePlainString(DicomTag(0x0008, 0x0120), "UR");
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
745 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
746 dicom.ReplacePlainString(DicomTag(0x0040, 0x0031), "UT");
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
747
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
748 DicomWebJsonVisitor visitor;
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
749 dicom.Apply(visitor);
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
750
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
751 std::string s;
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
752
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
753 // 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
754 // automatically copied by DCMTK from tag (0008,0016)
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
755 ASSERT_EQ("UI", visitor.GetResult() ["00020002"]["vr"].asString());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
756 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
757 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
758 ASSERT_EQ("AE", visitor.GetResult() ["00400241"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
759 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
760 ASSERT_EQ("AS", visitor.GetResult() ["00101010"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
761 ASSERT_EQ("AT", visitor.GetResult() ["00209165"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
762 ASSERT_EQ("00100020", visitor.GetResult() ["00209165"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
763 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
764 ASSERT_EQ("CS", visitor.GetResult() ["00080052"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
765 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
766 ASSERT_EQ("DA", visitor.GetResult() ["00080012"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
767 ASSERT_EQ("DS", visitor.GetResult() ["00101020"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
768 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
769 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
770 ASSERT_EQ("DT", visitor.GetResult() ["0008002A"]["Value"][0].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
771 ASSERT_EQ("FL", visitor.GetResult() ["00109431"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
772 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
773 ASSERT_EQ("FD", visitor.GetResult() ["00081163"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
774 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
775 ASSERT_EQ("IS", visitor.GetResult() ["00081160"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
776 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
777 ASSERT_EQ("LO", visitor.GetResult() ["00080070"]["vr"].asString());
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
778 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
779 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
780 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
781
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
782 ASSERT_EQ("OB", visitor.GetResult() ["00282000"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
783 Toolbox::DecodeBase64(s, visitor.GetResult() ["00282000"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
784 ASSERT_EQ("OB", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
785
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
786 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
787 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
788 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
789 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
790 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
791 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
792 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
793 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
794 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
795 #endif
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
796
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
797 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
798 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
799
3210
4a1c47e20685 fix for dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3209
diff changeset
800 #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
801 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
802 Toolbox::DecodeBase64(s, visitor.GetResult() ["00660040"]["InlineBinary"].asString());
3211
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3210
diff changeset
803 ASSERT_EQ("46", s);
3694
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3693
diff changeset
804 #elif DCMTK_VERSION_NUMBER == 361
3693
7f0caf198641 fix dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
805 ASSERT_EQ("UL", visitor.GetResult() ["00660040"]["vr"].asString());
7f0caf198641 fix dcmtk 3.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
806 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
807 #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
808 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
809 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
810 #endif
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
811
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
812 ASSERT_EQ("OW", visitor.GetResult() ["00281201"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
813 Toolbox::DecodeBase64(s, visitor.GetResult() ["00281201"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
814 ASSERT_EQ("OWOW", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
815
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
816 ASSERT_EQ("PN", visitor.GetResult() ["00100010"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
817 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
818
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
819 ASSERT_EQ("SH", visitor.GetResult() ["00080050"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
820 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
821
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
822 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
823 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
824
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
825 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
826 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
827
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
828 ASSERT_EQ("ST", visitor.GetResult() ["00080081"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
829 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
830
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
831 ASSERT_EQ("TM", visitor.GetResult() ["00080013"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
832 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
833
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
834 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
835 ASSERT_EQ("UC", visitor.GetResult() ["00080119"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
836 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
837 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
838 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
839 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
840 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
841 #endif
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
842
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
843 ASSERT_EQ("UI", visitor.GetResult() ["00080016"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
844 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
845
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
846 ASSERT_EQ("UL", visitor.GetResult() ["00081161"]["vr"].asString());
3212
304184684107 Orthanc-1.5.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3211
diff changeset
847 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
848
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
849 ASSERT_EQ("UN", visitor.GetResult() ["43421234"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
850 Toolbox::DecodeBase64(s, visitor.GetResult() ["43421234"]["InlineBinary"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
851 ASSERT_EQ("UN", s);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
852
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
853 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
854 ASSERT_EQ("UR", visitor.GetResult() ["00080120"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
855 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
856 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
857 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
858 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
859 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
860 #endif
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
861
3209
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
862 #if DCMTK_VERSION_NUMBER >= 361
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
863 ASSERT_EQ("US", visitor.GetResult() ["00080301"]["vr"].asString());
3212
304184684107 Orthanc-1.5.4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3211
diff changeset
864 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
865 #else
f6374c36a671 documentation of DICOMweb in SDK, compatibility with DCMTK 3.6.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3203
diff changeset
866 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
867 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
868 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
869 #endif
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
870
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
871 ASSERT_EQ("UT", visitor.GetResult() ["00400031"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
872 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
873
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
874 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
875 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
876
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
877 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
878 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
879 m.FromDicomWeb(visitor.GetResult());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
880 ASSERT_EQ(31u, m.GetSize());
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
881
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
882 std::string s;
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
883 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
884 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
885 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
886 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
887 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
888 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
889 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
890 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
891 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
892 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
893 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
894 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
895 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
896 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
897 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
898
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
899 #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
900 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
901 #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
902 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
903 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
904 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
905 #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
906
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
907 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
908 ASSERT_FLOAT_EQ(2.71828f, boost::lexical_cast<float>(s));
3518
a57c8163d9ae DicomMap::GetStringValue()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3497
diff changeset
909 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
910 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
911 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
912 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
913 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
914 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
915 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
916 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
917 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
918 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
919 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
920
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
921 #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
922 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
923 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
924 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
925 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
926 #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
927 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
928 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
929 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
930 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
931 #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
932
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
933 }
3198
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
934 }
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
935
7724ed267b5c unit testing dicomweb conversion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3197
diff changeset
936
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
937 TEST(DicomWebJson, Sequence)
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
938 {
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
939 ParsedDicomFile dicom(false);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
940
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
941 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
942 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
943
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
944 for (unsigned int i = 0; i < 3; i++)
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
945 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3694
diff changeset
946 std::unique_ptr<DcmItem> item(new DcmItem);
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
947 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
948 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, s.c_str(), OFFalse);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
949 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
950 }
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
951
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
952 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
953 }
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
954
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
955 DicomWebJsonVisitor visitor;
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
956 dicom.Apply(visitor);
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
957
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
958 ASSERT_EQ("SQ", visitor.GetResult() ["00081115"]["vr"].asString());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
959 ASSERT_EQ(3u, visitor.GetResult() ["00081115"]["Value"].size());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
960
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
961 std::set<std::string> items;
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
962
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
963 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
964 {
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
965 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
966 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
967 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
968 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
969 }
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
970
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
971 ASSERT_EQ(3u, items.size());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
972 ASSERT_TRUE(items.find("item0") != items.end());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
973 ASSERT_TRUE(items.find("item1") != items.end());
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
974 ASSERT_TRUE(items.find("item2") != items.end());
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
975
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
976 std::string xml;
3201
b69fe409cb4d dicomweb json to xml
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3200
diff changeset
977 visitor.FormatXml(xml);
3496
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
978
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
979 {
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
980 DicomMap m;
109631ed3564 DicomMap::FromDicomWeb()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3217
diff changeset
981 m.FromDicomWeb(visitor.GetResult());
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
982 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
983 }
3199
9316f341e40f unit testing json for dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3198
diff changeset
984 }
3581
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
985
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
986
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
987 TEST(DicomWebJson, PixelSpacing)
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
988 {
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
989 // 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
990 // correctly handled (dot "." vs comma ",")
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
991 ParsedDicomFile source(false);
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
992 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
993
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
994 DicomWebJsonVisitor visitor;
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
995 source.Apply(visitor);
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
996
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
997 DicomMap target;
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
998 target.FromDicomWeb(visitor.GetResult());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
999
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
1000 ASSERT_EQ("DS", visitor.GetResult() ["00280030"]["vr"].asString());
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
1001 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
1002 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
1003
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
1004 std::string s;
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
1005 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
1006 ASSERT_EQ(s, "1.5\\1.3");
4de1b019ca71 unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3551
diff changeset
1007 }
3651
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1008
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1009
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1010 TEST(DicomMap, MainTagNames)
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1011 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1012 ASSERT_EQ(3, ResourceType_Instance - ResourceType_Patient);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1013
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1014 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
1015 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1016 ResourceType level = static_cast<ResourceType>(i);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1017
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1018 std::set<DicomTag> tags;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1019 DicomMap::GetMainDicomTags(tags, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1020
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1021 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
1022 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1023 DicomMap a;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1024 a.SetValue(*it, "TEST", false);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1025
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1026 Json::Value json;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1027 a.DumpMainDicomTags(json, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1028
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1029 ASSERT_EQ(Json::objectValue, json.type());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1030 ASSERT_EQ(1u, json.getMemberNames().size());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1031
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1032 std::string name = json.getMemberNames() [0];
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1033 EXPECT_EQ(name, FromDcmtkBridge::GetTagName(*it, ""));
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1034
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1035 DicomMap b;
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1036 b.ParseMainDicomTags(json, level);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1037
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1038 ASSERT_EQ(1u, b.GetSize());
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1039 ASSERT_EQ("TEST", b.GetStringValue(*it, "", false));
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1040
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1041 std::string main = it->GetMainTagsName();
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1042 if (!main.empty())
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1043 {
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1044 ASSERT_EQ(main, name);
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1045 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1046 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1047 }
46cb00e4adbb DicomMap::DumpMainDicomTags() and DicomMap::ParseMainDicomTags()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
1048 }