annotate UnitTestsSources/FromDcmtkTests.cpp @ 1677:a903d57d9f0c db-changes

adaptation of search with patient tags at study level
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 05 Oct 2015 16:40:14 +0200
parents 3727a09e7b53
children ae09132e4237
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: 809
diff changeset
1 /**
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1091
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1091
diff changeset
4 * Department, University Hospital of Liege, Belgium
827
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
5 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
6 * This program is free software: you can redistribute it and/or
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
7 * modify it under the terms of the GNU General Public License as
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
9 * License, or (at your option) any later version.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
10 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
11 * In addition, as a special exception, the copyright holders of this
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
12 * program give permission to link the code of its release with the
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
15 * the linked executables. You must obey the GNU General Public License
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
19 * you do not wish to do so, delete this exception statement from your
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
20 * version. If you delete this exception statement from all source files
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
21 * in the program, then also delete it here.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
22 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
23 * This program is distributed in the hope that it will be useful, but
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
26 * General Public License for more details.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
27 *
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
28 * You should have received a copy of the GNU General Public License
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
30 **/
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
31
3d6f9b7d0add precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 809
diff changeset
32
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 827
diff changeset
33 #include "PrecompiledHeadersUnitTests.h"
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "gtest/gtest.h"
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "../OrthancServer/FromDcmtkBridge.h"
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../OrthancServer/OrthancInitialization.h"
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 785
diff changeset
38 #include "../OrthancServer/DicomModification.h"
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
39 #include "../Core/OrthancException.h"
1612
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
40 #include "../Core/Images/ImageBuffer.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
41 #include "../Core/Images/PngReader.h"
96582230ddcb Core/ImageFormats folder renamed as Core/Images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1562
diff changeset
42 #include "../Core/Images/PngWriter.h"
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
43 #include "../Core/Uuid.h"
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
44 #include "../Resources/EncodingTests.h"
782
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 using namespace Orthanc;
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 TEST(DicomFormat, Tag)
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010)));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 ASSERT_EQ(0x0008, t.GetGroup());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 ASSERT_EQ(0x103E, t.GetElement());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 t = FromDcmtkBridge::ParseTag("0020-e040");
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 ASSERT_EQ(0x0020, t.GetGroup());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 ASSERT_EQ(0xe040, t.GetElement());
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 // Test ==() and !=() operators
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020));
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 }
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
a60040857ce6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
66 TEST(DicomModification, Basic)
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
67 {
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
68 DicomModification m;
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
69 m.SetupAnonymization();
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
70 //m.SetLevel(DicomRootLevel_Study);
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
71 //m.Replace(DICOM_TAG_PATIENT_ID, "coucou");
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
72 //m.Replace(DICOM_TAG_PATIENT_NAME, "coucou");
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
73
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
74 ParsedDicomFile o;
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
75 o.SaveToFile("UnitTestsResults/anon.dcm");
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
76
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
77 for (int i = 0; i < 10; i++)
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
78 {
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
79 char b[1024];
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
80 sprintf(b, "UnitTestsResults/anon%06d.dcm", i);
784
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
81 std::auto_ptr<ParsedDicomFile> f(o.Clone());
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
82 if (i > 4)
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
83 o.Replace(DICOM_TAG_SERIES_INSTANCE_UID, "coucou");
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
84 m.Apply(*f);
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
85 f->SaveToFile(b);
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
86 }
efd0215736d9 start of anonymization refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 782
diff changeset
87 }
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
88
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
89
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
90 TEST(DicomModification, Anonymization)
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
91 {
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
92 ASSERT_EQ(DICOM_TAG_PATIENT_NAME, FromDcmtkBridge::ParseTag("PatientName"));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
93
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
94 const DicomTag privateTag(0x0045, 0x0010);
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
95 const DicomTag privateTag2(FromDcmtkBridge::ParseTag("0031-1020"));
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
96 ASSERT_TRUE(FromDcmtkBridge::IsPrivateTag(privateTag));
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
97 ASSERT_TRUE(FromDcmtkBridge::IsPrivateTag(privateTag2));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
98 ASSERT_EQ(0x0031, privateTag2.GetGroup());
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
99 ASSERT_EQ(0x1020, privateTag2.GetElement());
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
100
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
101 std::string s;
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
102 ParsedDicomFile o;
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
103 o.Replace(DICOM_TAG_PATIENT_NAME, "coucou");
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
104 ASSERT_FALSE(o.GetTagValue(s, privateTag));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
105 o.Insert(privateTag, "private tag");
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
106 ASSERT_TRUE(o.GetTagValue(s, privateTag));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
107 ASSERT_STREQ("private tag", s.c_str());
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
108
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
109 ASSERT_FALSE(o.GetTagValue(s, privateTag2));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
110 ASSERT_THROW(o.Replace(privateTag2, "hello", DicomReplaceMode_ThrowIfAbsent), OrthancException);
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
111 ASSERT_FALSE(o.GetTagValue(s, privateTag2));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
112 o.Replace(privateTag2, "hello", DicomReplaceMode_IgnoreIfAbsent);
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
113 ASSERT_FALSE(o.GetTagValue(s, privateTag2));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
114 o.Replace(privateTag2, "hello", DicomReplaceMode_InsertIfAbsent);
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
115 ASSERT_TRUE(o.GetTagValue(s, privateTag2));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
116 ASSERT_STREQ("hello", s.c_str());
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
117 o.Replace(privateTag2, "hello world");
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
118 ASSERT_TRUE(o.GetTagValue(s, privateTag2));
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
119 ASSERT_STREQ("hello world", s.c_str());
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
120
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
121 ASSERT_TRUE(o.GetTagValue(s, DICOM_TAG_PATIENT_NAME));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
122 ASSERT_FALSE(Toolbox::IsUuid(s));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
123
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
124 DicomModification m;
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
125 m.SetupAnonymization();
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
126 m.Keep(privateTag);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
127
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
128 m.Apply(o);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
129
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
130 ASSERT_TRUE(o.GetTagValue(s, DICOM_TAG_PATIENT_NAME));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
131 ASSERT_TRUE(Toolbox::IsUuid(s));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
132 ASSERT_TRUE(o.GetTagValue(s, privateTag));
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
133 ASSERT_STREQ("private tag", s.c_str());
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
134
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
135 m.SetupAnonymization();
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
136 m.Apply(o);
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
137 ASSERT_FALSE(o.GetTagValue(s, privateTag));
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
138 }
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
139
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 967
diff changeset
140
802
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 800
diff changeset
141 #include <dcmtk/dcmdata/dcuid.h>
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
142
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
143 TEST(DicomModification, Png)
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
144 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
145 // Red dot in http://en.wikipedia.org/wiki/Data_URI_scheme (RGBA image)
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
146 std::string s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
147
1641
4e56b5a206b7 Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
148 std::string m, cc;
4e56b5a206b7 Support of binary tags encoded using data URI scheme
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1612
diff changeset
149 Toolbox::DecodeDataUriScheme(m, cc, s);
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
150
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
151 ASSERT_EQ("image/png", m);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
152
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
153 PngReader reader;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
154 reader.ReadFromMemory(cc);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
155
1492
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1417
diff changeset
156 ASSERT_EQ(5u, reader.GetHeight());
9f66a12eb8fc fix warnings for gcc 5
jodogne
parents: 1417
diff changeset
157 ASSERT_EQ(5u, reader.GetWidth());
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
158 ASSERT_EQ(PixelFormat_RGBA32, reader.GetFormat());
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
159
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
160 ParsedDicomFile o;
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
161 o.EmbedContent(s);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
162 o.SaveToFile("UnitTestsResults/png1.dcm");
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
163
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
164 // Red dot, without alpha channel
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
165 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDTcIn2+8BgAAACJJREFUCNdj/P//PwMjIwME/P/P+J8BBTAxEOL/R9Lx/z8AynoKAXOeiV8AAAAASUVORK5CYII=";
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
166 o.EmbedContent(s);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
167 o.SaveToFile("UnitTestsResults/png2.dcm");
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
168
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
169 // Check box in Graylevel8
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
170 s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3gUGDDcB53FulQAAAElJREFUGNNtj0sSAEEEQ1+U+185s1CtmRkblQ9CZldsKHJDk6DLGLJa6chjh0ooQmpjXMM86zPwydGEj6Ed/UGykkEM8X+p3u8/8LcOJIWLGeMAAAAASUVORK5CYII=";
1562
2084b7c20478 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1492
diff changeset
171 o.EmbedContent(s);
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
172 //o.Replace(DICOM_TAG_SOP_CLASS_UID, UID_DigitalXRayImageStorageForProcessing);
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
173 o.SaveToFile("UnitTestsResults/png3.dcm");
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
174
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
175
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
176 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
177 // Gradient in Graylevel16
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
178
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
179 ImageBuffer img;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
180 img.SetWidth(256);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
181 img.SetHeight(256);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
182 img.SetFormat(PixelFormat_Grayscale16);
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
183
1654
3727a09e7b53 fix some icc warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1641
diff changeset
184 uint16_t v = 0;
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
185 for (unsigned int y = 0; y < img.GetHeight(); y++)
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
186 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
187 uint16_t *p = reinterpret_cast<uint16_t*>(img.GetAccessor().GetRow(y));
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
188 for (unsigned int x = 0; x < img.GetWidth(); x++, p++, v++)
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
189 {
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
190 *p = v;
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
191 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
192 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
193
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
194 o.EmbedImage(img.GetAccessor());
803
4689e400e0fa directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 802
diff changeset
195 o.SaveToFile("UnitTestsResults/png4.dcm");
800
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
196 }
ecedd89055db generation of DICOM images from PNG files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
197 }
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
198
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
199
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
200 TEST(FromDcmtkBridge, Encodings1)
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
201 {
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
202 for (unsigned int i = 0; i < testEncodingsCount; i++)
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
203 {
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
204 std::string source(testEncodingsEncoded[i]);
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
205 std::string expected(testEncodingsExpected[i]);
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
206 std::string s = Toolbox::ConvertToUtf8(source, testEncodings[i]);
1089
5ea0b56e850d logging in test
jodogne
parents: 1088
diff changeset
207 std::cout << EnumerationToString(testEncodings[i]) << std::endl;
5ea0b56e850d logging in test
jodogne
parents: 1088
diff changeset
208 EXPECT_EQ(expected, s);
1088
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
209 }
6fd4434c1bcf unit tests for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
210 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
211
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
212
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
213 TEST(FromDcmtkBridge, Enumerations)
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
214 {
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
215 Encoding e;
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
216
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
217 ASSERT_FALSE(GetDicomEncoding(e, ""));
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
218 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 6")); ASSERT_EQ(Encoding_Utf8, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
219
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
220 // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ - Table C.12-2
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
221 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 100")); ASSERT_EQ(Encoding_Latin1, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
222 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 101")); ASSERT_EQ(Encoding_Latin2, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
223 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 109")); ASSERT_EQ(Encoding_Latin3, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
224 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 110")); ASSERT_EQ(Encoding_Latin4, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
225 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 144")); ASSERT_EQ(Encoding_Cyrillic, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
226 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 127")); ASSERT_EQ(Encoding_Arabic, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
227 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 126")); ASSERT_EQ(Encoding_Greek, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
228 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 138")); ASSERT_EQ(Encoding_Hebrew, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
229 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 148")); ASSERT_EQ(Encoding_Latin5, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
230 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 13")); ASSERT_EQ(Encoding_Japanese, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
231 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 166")); ASSERT_EQ(Encoding_Thai, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
232
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
233 // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ - Table C.12-3
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
234 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 6")); ASSERT_EQ(Encoding_Utf8, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
235 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 100")); ASSERT_EQ(Encoding_Latin1, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
236 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 101")); ASSERT_EQ(Encoding_Latin2, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
237 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 109")); ASSERT_EQ(Encoding_Latin3, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
238 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 110")); ASSERT_EQ(Encoding_Latin4, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
239 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 144")); ASSERT_EQ(Encoding_Cyrillic, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
240 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 127")); ASSERT_EQ(Encoding_Arabic, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
241 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 126")); ASSERT_EQ(Encoding_Greek, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
242 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 138")); ASSERT_EQ(Encoding_Hebrew, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
243 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 148")); ASSERT_EQ(Encoding_Latin5, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
244 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 13")); ASSERT_EQ(Encoding_Japanese, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
245 ASSERT_TRUE(GetDicomEncoding(e, "ISO 2022 IR 166")); ASSERT_EQ(Encoding_Thai, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
246
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
247 // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ - Table C.12-4
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
248 ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 87")); //ASSERT_EQ(Encoding_JapaneseKanji, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
249 ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 159")); //ASSERT_EQ(Encoding_JapaneseKanjiSupplementary, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
250 ASSERT_FALSE(GetDicomEncoding(e, "ISO 2022 IR 149")); //ASSERT_EQ(Encoding_Korean, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
251
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
252 // http://www.dabsoft.ch/dicom/3/C.12.1.1.2/ - Table C.12-5
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
253 ASSERT_TRUE(GetDicomEncoding(e, "ISO_IR 192")); ASSERT_EQ(Encoding_Utf8, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
254 ASSERT_TRUE(GetDicomEncoding(e, "GB18030")); ASSERT_EQ(Encoding_Chinese, e);
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
255 }
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
256
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
257
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
258 TEST(FromDcmtkBridge, Encodings3)
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
259 {
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
260 for (unsigned int i = 0; i < testEncodingsCount; i++)
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
261 {
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
262 std::cout << EnumerationToString(testEncodings[i]) << std::endl;
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
263 std::string dicom;
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
264
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
265 {
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
266 ParsedDicomFile f;
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
267 f.SetEncoding(testEncodings[i]);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
268 f.Insert(DICOM_TAG_PATIENT_NAME, testEncodingsEncoded[i]);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
269 f.SaveToMemoryBuffer(dicom);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
270 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
271
1347
60cc0ee61edb fix issue 32
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1334
diff changeset
272 if (testEncodings[i] != Encoding_Windows1251)
1091
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
273 {
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
274 ParsedDicomFile g(dicom);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
275
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
276 if (testEncodings[i] != Encoding_Ascii)
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
277 {
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
278 ASSERT_EQ(testEncodings[i], g.GetEncoding());
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
279 }
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
280
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
281 std::string tag;
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
282 ASSERT_TRUE(g.GetTagValue(tag, DICOM_TAG_PATIENT_NAME));
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
283 ASSERT_EQ(std::string(testEncodingsExpected[i]), tag);
a66224eec125 encoding tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1090
diff changeset
284 }
1090
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
285 }
e494ceb8d763 support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1089
diff changeset
286 }
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
287
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
288
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
289 TEST(FromDcmtkBridge, ValueRepresentation)
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
290 {
1417
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
291 ASSERT_EQ(ValueRepresentation_PatientName,
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
292 FromDcmtkBridge::GetValueRepresentation(DICOM_TAG_PATIENT_NAME));
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
293 ASSERT_EQ(ValueRepresentation_Date,
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
294 FromDcmtkBridge::GetValueRepresentation(DicomTag(0x0008, 0x0020) /* StudyDate */));
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
295 ASSERT_EQ(ValueRepresentation_Time,
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
296 FromDcmtkBridge::GetValueRepresentation(DicomTag(0x0008, 0x0030) /* StudyTime */));
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
297 ASSERT_EQ(ValueRepresentation_DateTime,
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
298 FromDcmtkBridge::GetValueRepresentation(DicomTag(0x0008, 0x002a) /* AcquisitionDateTime */));
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
299 ASSERT_EQ(ValueRepresentation_Other,
8e23f16a198d fix issues 35 and 37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1360
diff changeset
300 FromDcmtkBridge::GetValueRepresentation(DICOM_TAG_PATIENT_ID));
1360
0649c5aef34a DicomFindQuery
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1347
diff changeset
301 }