Mercurial > hg > orthanc
annotate OrthancServer/UnitTestsSources/UnitTestsMain.cpp @ 4870:43e613a7756b
upgrade to year 2022
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Jan 2022 11:15:42 +0100 |
parents | 7053502fbf97 |
children | 6eff25f70121 |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1102
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
7 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
8 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
9 * 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:
810
diff
changeset
|
10 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
11 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
12 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
13 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
14 * 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:
810
diff
changeset
|
15 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
16 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
17 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
18 * 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:
810
diff
changeset
|
19 * 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:
810
diff
changeset
|
20 * 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:
810
diff
changeset
|
21 * 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:
810
diff
changeset
|
22 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
23 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
24 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
25 * 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:
810
diff
changeset
|
26 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
28 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
29 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
30 * 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:
810
diff
changeset
|
31 * 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:
810
diff
changeset
|
32 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
33 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
34 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
827
diff
changeset
|
35 #include "PrecompiledHeadersUnitTests.h" |
4062 | 36 #include <gtest/gtest.h> |
4059
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
37 |
4105
c02a2d9efbc2
move FromDcmtkBridge::ExecuteToDicom() to LuaFunctionCall, to remove dependency of DCMTK on Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
38 #include "../../OrthancFramework/Sources/DicomFormat/DicomArray.h" |
4059
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
39 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
40 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomFile.h" |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
41 #include "../../OrthancFramework/Sources/DicomParsing/ToDcmtkBridge.h" |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
42 #include "../../OrthancFramework/Sources/EnumerationDictionary.h" |
4046
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
43 #include "../../OrthancFramework/Sources/Images/Image.h" |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
44 #include "../../OrthancFramework/Sources/Images/PngWriter.h" |
4059
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
45 #include "../../OrthancFramework/Sources/Logging.h" |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
46 #include "../../OrthancFramework/Sources/OrthancException.h" |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
47 #include "../../OrthancFramework/Sources/Toolbox.h" |
0 | 48 |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
49 #include "../Plugins/Engine/PluginsEnumerations.h" |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
50 #include "../Sources/DicomInstanceToStore.h" |
4046
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
51 #include "../Sources/OrthancConfiguration.h" // For the FontRegistry |
4045 | 52 #include "../Sources/OrthancInitialization.h" |
53 #include "../Sources/ServerEnumerations.h" | |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
54 #include "../Sources/ServerToolbox.h" |
4059
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
55 #include "../Sources/StorageCommitmentReports.h" |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
56 |
4062 | 57 #include <OrthancServerResources.h> |
58 | |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
59 #include <dcmtk/dcmdata/dcdeftag.h> |
0 | 60 |
1337 | 61 |
63 | 62 using namespace Orthanc; |
0 | 63 |
64 | |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
65 TEST(EnumerationDictionary, Simple) |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
66 { |
3991
5d2348b39392
turning toolbox namespaces into classes to control visibility in shared libraries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3987
diff
changeset
|
67 EnumerationDictionary<MetadataType> d; |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
68 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
69 ASSERT_THROW(d.Translate("ReceptionDate"), OrthancException); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
70 ASSERT_EQ(MetadataType_ModifiedFrom, d.Translate("5")); |
436
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
435
diff
changeset
|
71 ASSERT_EQ(256, d.Translate("256")); |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
72 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
73 d.Add(MetadataType_Instance_ReceptionDate, "ReceptionDate"); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
74 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
75 ASSERT_EQ(MetadataType_Instance_ReceptionDate, d.Translate("ReceptionDate")); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
76 ASSERT_EQ(MetadataType_Instance_ReceptionDate, d.Translate("2")); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
77 ASSERT_EQ("ReceptionDate", d.Translate(MetadataType_Instance_ReceptionDate)); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
78 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
79 ASSERT_THROW(d.Add(MetadataType_Instance_ReceptionDate, "Hello"), OrthancException); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
80 ASSERT_THROW(d.Add(MetadataType_ModifiedFrom, "ReceptionDate"), OrthancException); // already used |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
81 ASSERT_THROW(d.Add(MetadataType_ModifiedFrom, "1024"), OrthancException); // cannot register numbers |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
82 d.Add(MetadataType_ModifiedFrom, "ModifiedFrom"); // ok |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
83 } |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
84 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
85 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
86 TEST(EnumerationDictionary, ServerEnumerations) |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
87 { |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
88 ASSERT_STREQ("Patient", EnumerationToString(ResourceType_Patient)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
89 ASSERT_STREQ("Study", EnumerationToString(ResourceType_Study)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
90 ASSERT_STREQ("Series", EnumerationToString(ResourceType_Series)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
91 ASSERT_STREQ("Instance", EnumerationToString(ResourceType_Instance)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
92 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
93 ASSERT_STREQ("ModifiedSeries", EnumerationToString(ChangeType_ModifiedSeries)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
94 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
95 ASSERT_STREQ("Failure", EnumerationToString(StoreStatus_Failure)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
96 ASSERT_STREQ("Success", EnumerationToString(StoreStatus_Success)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
97 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
98 ASSERT_STREQ("CompletedSeries", EnumerationToString(ChangeType_CompletedSeries)); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
99 |
437 | 100 ASSERT_EQ("IndexInSeries", EnumerationToString(MetadataType_Instance_IndexInSeries)); |
101 ASSERT_EQ("LastUpdate", EnumerationToString(MetadataType_LastUpdate)); | |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
102 |
559 | 103 ASSERT_EQ(ResourceType_Patient, StringToResourceType("PATienT")); |
104 ASSERT_EQ(ResourceType_Study, StringToResourceType("STudy")); | |
105 ASSERT_EQ(ResourceType_Series, StringToResourceType("SeRiEs")); | |
106 ASSERT_EQ(ResourceType_Instance, StringToResourceType("INStance")); | |
107 ASSERT_EQ(ResourceType_Instance, StringToResourceType("IMagE")); | |
108 ASSERT_THROW(StringToResourceType("heLLo"), OrthancException); | |
109 | |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
110 ASSERT_EQ(2047, StringToMetadata("2047")); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
111 ASSERT_THROW(StringToMetadata("Ceci est un test"), OrthancException); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
112 ASSERT_THROW(RegisterUserMetadata(128, ""), OrthancException); // too low (< 1024) |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
113 ASSERT_THROW(RegisterUserMetadata(128000, ""), OrthancException); // too high (> 65535) |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
114 RegisterUserMetadata(2047, "Ceci est un test"); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
115 ASSERT_EQ(2047, StringToMetadata("2047")); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
116 ASSERT_EQ(2047, StringToMetadata("Ceci est un test")); |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1428
diff
changeset
|
117 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1428
diff
changeset
|
118 ASSERT_STREQ("Generic", EnumerationToString(StringToModalityManufacturer("Generic"))); |
2319
ae6245053bcf
made some manufacturer obsolete: MedInria (that was not used), Syngovia & AgfaImpax (replaced by GenericNoWildcardInDates) + added 'GenericNoWildcards'
amazy
parents:
2313
diff
changeset
|
119 ASSERT_STREQ("GenericNoWildcardInDates", EnumerationToString(StringToModalityManufacturer("GenericNoWildcardInDates"))); |
2352
3ab96768d144
Fix issue 52 (DICOM level security association problems)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2319
diff
changeset
|
120 ASSERT_STREQ("GenericNoUniversalWildcard", EnumerationToString(StringToModalityManufacturer("GenericNoUniversalWildcard"))); |
1852
efbc3afd6cd3
Efilm and Vitrea manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1846
diff
changeset
|
121 ASSERT_STREQ("Vitrea", EnumerationToString(StringToModalityManufacturer("Vitrea"))); |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2841
diff
changeset
|
122 ASSERT_STREQ("GE", EnumerationToString(StringToModalityManufacturer("GE"))); |
2319
ae6245053bcf
made some manufacturer obsolete: MedInria (that was not used), Syngovia & AgfaImpax (replaced by GenericNoWildcardInDates) + added 'GenericNoWildcards'
amazy
parents:
2313
diff
changeset
|
123 // backward compatibility tests (to remove once we make these manufacturer really obsolete) |
ae6245053bcf
made some manufacturer obsolete: MedInria (that was not used), Syngovia & AgfaImpax (replaced by GenericNoWildcardInDates) + added 'GenericNoWildcards'
amazy
parents:
2313
diff
changeset
|
124 ASSERT_STREQ("Generic", EnumerationToString(StringToModalityManufacturer("MedInria"))); |
ae6245053bcf
made some manufacturer obsolete: MedInria (that was not used), Syngovia & AgfaImpax (replaced by GenericNoWildcardInDates) + added 'GenericNoWildcards'
amazy
parents:
2313
diff
changeset
|
125 ASSERT_STREQ("Generic", EnumerationToString(StringToModalityManufacturer("EFilm2"))); |
3561
bdafff1ce443
C-Find SCU at Instance level now sets the 0008,0052 tag to IMAGE per default (was INSTANCE). Source: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/orthanc-users/FYxHXzlaQ0M/rn6d0SowAAAJ
Alain Mazy <alain@mazy.be>
parents:
3497
diff
changeset
|
126 ASSERT_STREQ("Generic", EnumerationToString(StringToModalityManufacturer("ClearCanvas"))); |
bdafff1ce443
C-Find SCU at Instance level now sets the 0008,0052 tag to IMAGE per default (was INSTANCE). Source: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/orthanc-users/FYxHXzlaQ0M/rn6d0SowAAAJ
Alain Mazy <alain@mazy.be>
parents:
3497
diff
changeset
|
127 ASSERT_STREQ("Generic", EnumerationToString(StringToModalityManufacturer("Dcm4Chee"))); |
2319
ae6245053bcf
made some manufacturer obsolete: MedInria (that was not used), Syngovia & AgfaImpax (replaced by GenericNoWildcardInDates) + added 'GenericNoWildcards'
amazy
parents:
2313
diff
changeset
|
128 ASSERT_STREQ("GenericNoWildcardInDates", EnumerationToString(StringToModalityManufacturer("SyngoVia"))); |
ae6245053bcf
made some manufacturer obsolete: MedInria (that was not used), Syngovia & AgfaImpax (replaced by GenericNoWildcardInDates) + added 'GenericNoWildcards'
amazy
parents:
2313
diff
changeset
|
129 ASSERT_STREQ("GenericNoWildcardInDates", EnumerationToString(StringToModalityManufacturer("AgfaImpax"))); |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4177
diff
changeset
|
130 |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4177
diff
changeset
|
131 ASSERT_STREQ("default", EnumerationToString(StringToVerbosity("default"))); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4177
diff
changeset
|
132 ASSERT_STREQ("verbose", EnumerationToString(StringToVerbosity("verbose"))); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4177
diff
changeset
|
133 ASSERT_STREQ("trace", EnumerationToString(StringToVerbosity("trace"))); |
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4177
diff
changeset
|
134 ASSERT_THROW(StringToVerbosity("nope"), OrthancException); |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
135 } |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
136 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
137 |
450 | 138 |
4046
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
139 TEST(FontRegistry, Basic) |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
140 { |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
141 Orthanc::Image s(Orthanc::PixelFormat_RGB24, 640, 480, false); |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
142 memset(s.GetBuffer(), 0, s.GetPitch() * s.GetHeight()); |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
143 |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
144 { |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
145 Orthanc::OrthancConfiguration::ReaderLock lock; |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
146 ASSERT_GE(1u, lock.GetConfiguration().GetFontRegistry().GetSize()); |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
147 lock.GetConfiguration().GetFontRegistry().GetFont(0).Draw |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
148 (s, "Hello world É\n\rComment ça va ?\nq", 50, 60, 255, 0, 0); |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
149 } |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
150 |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
151 Orthanc::PngWriter w; |
4311
cb9aef006229
turning IImageWriter into a pure interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4275
diff
changeset
|
152 Orthanc::IImageWriter::WriteToFile(w, "UnitTestsResults/font.png", s); |
4046
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
153 } |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
154 |
7ff1e6c80627
moving ImageTests.cpp to framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
155 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
156 TEST(FromDcmtkBridge, ValueRepresentationConversions) |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
157 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
158 #if ORTHANC_ENABLE_PLUGINS == 1 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
159 ASSERT_EQ(1, ValueRepresentation_ApplicationEntity); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
160 ASSERT_EQ(1, OrthancPluginValueRepresentation_AE); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
161 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
162 for (int i = ValueRepresentation_ApplicationEntity; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
163 i <= ValueRepresentation_NotSupported; i++) |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
164 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
165 ValueRepresentation vr = static_cast<ValueRepresentation>(i); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
166 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
167 if (vr == ValueRepresentation_NotSupported) |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
168 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
169 ASSERT_THROW(ToDcmtkBridge::Convert(vr), OrthancException); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
170 ASSERT_THROW(Plugins::Convert(vr), OrthancException); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
171 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
172 else if (vr == ValueRepresentation_OtherDouble || |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
173 vr == ValueRepresentation_OtherLong || |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
174 vr == ValueRepresentation_UniversalResource || |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
175 vr == ValueRepresentation_UnlimitedCharacters) |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
176 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
177 // These VR are not supported as of DCMTK 3.6.0 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
178 ASSERT_THROW(ToDcmtkBridge::Convert(vr), OrthancException); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
179 ASSERT_EQ(OrthancPluginValueRepresentation_UN, Plugins::Convert(vr)); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
180 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
181 else |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
182 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
183 ASSERT_EQ(vr, FromDcmtkBridge::Convert(ToDcmtkBridge::Convert(vr))); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
184 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
185 OrthancPluginValueRepresentation plugins = Plugins::Convert(vr); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
186 ASSERT_EQ(vr, Plugins::Convert(plugins)); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
187 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
188 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
189 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
190 for (int i = OrthancPluginValueRepresentation_AE; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
191 i <= OrthancPluginValueRepresentation_UT; i++) |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
192 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
193 OrthancPluginValueRepresentation plugins = static_cast<OrthancPluginValueRepresentation>(i); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
194 ValueRepresentation orthanc = Plugins::Convert(plugins); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
195 ASSERT_EQ(plugins, Plugins::Convert(orthanc)); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
196 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
197 #endif |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
198 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
199 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
200 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
201 |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
202 TEST(DicomMap, DicomAsJson) |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
203 { |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
204 // This is a Latin-1 test string: "crane" with a circumflex accent |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
205 const unsigned char raw[] = { 0x63, 0x72, 0xe2, 0x6e, 0x65 }; |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
206 std::string latin1((char*) &raw[0], sizeof(raw) / sizeof(char)); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
207 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
208 std::string utf8 = Toolbox::ConvertToUtf8(latin1, Encoding_Latin1, false); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
209 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
210 ParsedDicomFile dicom(false); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
211 dicom.SetEncoding(Encoding_Latin1); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
212 dicom.ReplacePlainString(DICOM_TAG_PATIENT_NAME, "Hello"); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
213 dicom.ReplacePlainString(DICOM_TAG_STUDY_DESCRIPTION, utf8); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
214 dicom.ReplacePlainString(DICOM_TAG_SERIES_DESCRIPTION, std::string(ORTHANC_MAXIMUM_TAG_LENGTH, 'a')); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
215 dicom.ReplacePlainString(DICOM_TAG_MANUFACTURER, std::string(ORTHANC_MAXIMUM_TAG_LENGTH + 1, 'a')); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
216 dicom.ReplacePlainString(DICOM_TAG_PIXEL_DATA, "binary"); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
217 dicom.ReplacePlainString(DICOM_TAG_ROWS, "512"); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
218 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
219 DcmDataset& dataset = *dicom.GetDcmtkObject().getDataset(); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
220 dataset.insertEmptyElement(DCM_StudyID, OFFalse); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
221 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
222 { |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
223 std::unique_ptr<DcmSequenceOfItems> sequence(new DcmSequenceOfItems(DCM_ReferencedSeriesSequence)); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
224 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
225 { |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
226 std::unique_ptr<DcmItem> item(new DcmItem); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
227 item->putAndInsertString(DCM_ReferencedSOPInstanceUID, "nope", OFFalse); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
228 ASSERT_TRUE(sequence->insert(item.release(), false, false).good()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
229 } |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
230 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
231 ASSERT_TRUE(dataset.insert(sequence.release(), false, false).good()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
232 } |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
233 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
234 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
235 // Check re-encoding |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
236 DcmElement* element = NULL; |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
237 ASSERT_TRUE(dataset.findAndGetElement(DCM_StudyDescription, element).good() && |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
238 element != NULL); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
239 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
240 char* c = NULL; |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
241 ASSERT_TRUE(element != NULL && |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
242 element->isLeaf() && |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
243 element->isaString() && |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
244 element->getString(c).good()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
245 ASSERT_EQ(0, memcmp(c, raw, latin1.length())); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
246 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
247 ASSERT_TRUE(dataset.findAndGetElement(DCM_Rows, element).good() && |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
248 element != NULL && |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
249 element->getTag().getEVR() == EVR_US); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
250 |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4504
diff
changeset
|
251 std::unique_ptr<DicomInstanceToStore> toStore(DicomInstanceToStore::CreateFromParsedDicomFile(dicom)); |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
252 |
4504
7d1eabfac6e0
removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
253 Json::Value dicomAsJson; |
4508
8f9090b137f1
Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4504
diff
changeset
|
254 OrthancConfiguration::DefaultDicomDatasetToJson(dicomAsJson, toStore->GetParsedDicomFile()); |
4504
7d1eabfac6e0
removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
255 |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
256 DicomMap m; |
4504
7d1eabfac6e0
removed cached dicom-as-json from DicomInstanceToStore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
257 m.FromDicomAsJson(dicomAsJson); |
4057
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
258 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
259 ASSERT_EQ("ISO_IR 100", m.GetValue(DICOM_TAG_SPECIFIC_CHARACTER_SET).GetContent()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
260 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
261 ASSERT_FALSE(m.GetValue(DICOM_TAG_PATIENT_NAME).IsBinary()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
262 ASSERT_EQ("Hello", m.GetValue(DICOM_TAG_PATIENT_NAME).GetContent()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
263 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
264 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).IsBinary()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
265 ASSERT_EQ(utf8, m.GetValue(DICOM_TAG_STUDY_DESCRIPTION).GetContent()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
266 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
267 ASSERT_FALSE(m.HasTag(DICOM_TAG_MANUFACTURER)); // Too long |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
268 ASSERT_FALSE(m.HasTag(DICOM_TAG_PIXEL_DATA)); // Pixel data |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
269 ASSERT_FALSE(m.HasTag(DICOM_TAG_REFERENCED_SERIES_SEQUENCE)); // Sequence |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
270 ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetGroup(), DCM_ReferencedSeriesSequence.getGroup()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
271 ASSERT_EQ(DICOM_TAG_REFERENCED_SERIES_SEQUENCE.GetElement(), DCM_ReferencedSeriesSequence.getElement()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
272 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
273 ASSERT_TRUE(m.HasTag(DICOM_TAG_SERIES_DESCRIPTION)); // Maximum length |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
274 ASSERT_FALSE(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).IsBinary()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
275 ASSERT_EQ(ORTHANC_MAXIMUM_TAG_LENGTH, |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
276 static_cast<int>(m.GetValue(DICOM_TAG_SERIES_DESCRIPTION).GetContent().length())); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
277 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
278 ASSERT_FALSE(m.GetValue(DICOM_TAG_ROWS).IsBinary()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
279 ASSERT_EQ("512", m.GetValue(DICOM_TAG_ROWS).GetContent()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
280 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
281 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsNull()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
282 ASSERT_FALSE(m.GetValue(DICOM_TAG_STUDY_ID).IsBinary()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
283 ASSERT_EQ("", m.GetValue(DICOM_TAG_STUDY_ID).GetContent()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
284 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
285 DicomArray a(m); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
286 ASSERT_EQ(6u, a.GetSize()); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
287 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
288 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
289 //dicom.SaveToFile("/tmp/test.dcm"); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
290 //std::cout << toStore.GetJson() << std::endl; |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
291 //a.Print(stdout); |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
292 } |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
293 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
294 |
8b7cd69806f2
move DicomMapTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
295 |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
296 namespace Orthanc |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
297 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
298 // Namespace for the "FRIEND_TEST()" directive in "FromDcmtkBridge" to apply: |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
299 // https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#private-class-members |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
300 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
301 static const DicomTag REFERENCED_STUDY_SEQUENCE(0x0008, 0x1110); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
302 static const DicomTag REFERENCED_PATIENT_SEQUENCE(0x0008, 0x1120); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
303 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
304 static void CreateSampleJson(Json::Value& a) |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
305 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
306 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
307 Json::Value b = Json::objectValue; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
308 b["PatientName"] = "Hello"; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
309 b["PatientID"] = "World"; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
310 b["StudyDescription"] = "Toto"; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
311 a.append(b); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
312 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
313 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
314 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
315 Json::Value b = Json::objectValue; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
316 b["PatientName"] = "data:application/octet-stream;base64,SGVsbG8y"; // echo -n "Hello2" | base64 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
317 b["PatientID"] = "World2"; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
318 a.append(b); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
319 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
320 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
321 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
322 TEST(FromDcmtkBridge, FromJson) |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
323 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
324 std::unique_ptr<DcmElement> element; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
325 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
326 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
327 Json::Value a; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
328 a = "Hello"; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
329 element.reset(FromDcmtkBridge::FromJson(DICOM_TAG_PATIENT_NAME, a, false, Encoding_Utf8, "")); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
330 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
331 Json::Value b; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
332 std::set<DicomTag> ignoreTagLength; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
333 ignoreTagLength.insert(DICOM_TAG_PATIENT_ID); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
334 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
335 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short, |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
336 DicomToJsonFlags_Default, 0, Encoding_Ascii, false, ignoreTagLength, 0); |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
337 ASSERT_TRUE(b.isMember("0010,0010")); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
338 ASSERT_EQ("Hello", b["0010,0010"].asString()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
339 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
340 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short, |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
341 DicomToJsonFlags_Default, 3, Encoding_Ascii, false, ignoreTagLength, 0); |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
342 ASSERT_TRUE(b["0010,0010"].isNull()); // "Hello" has more than 3 characters |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
343 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
344 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Full, |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
345 DicomToJsonFlags_Default, 3, Encoding_Ascii, false, ignoreTagLength, 0); |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
346 ASSERT_TRUE(b["0010,0010"].isObject()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
347 ASSERT_EQ("PatientName", b["0010,0010"]["Name"].asString()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
348 ASSERT_EQ("TooLong", b["0010,0010"]["Type"].asString()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
349 ASSERT_TRUE(b["0010,0010"]["Value"].isNull()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
350 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
351 ignoreTagLength.insert(DICOM_TAG_PATIENT_NAME); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
352 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short, |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
353 DicomToJsonFlags_Default, 3, Encoding_Ascii, false, ignoreTagLength, 0); |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
354 ASSERT_EQ("Hello", b["0010,0010"].asString()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
355 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
356 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
357 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
358 Json::Value a; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
359 a = "Hello"; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
360 // Cannot assign a string to a sequence |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
361 ASSERT_THROW(element.reset(FromDcmtkBridge::FromJson(REFERENCED_STUDY_SEQUENCE, a, false, Encoding_Utf8, "")), OrthancException); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
362 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
363 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
364 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
365 Json::Value a = Json::arrayValue; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
366 a.append("Hello"); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
367 // Cannot assign an array to a string |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
368 ASSERT_THROW(element.reset(FromDcmtkBridge::FromJson(DICOM_TAG_PATIENT_NAME, a, false, Encoding_Utf8, "")), OrthancException); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
369 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
370 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
371 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
372 Json::Value a; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
373 a = "data:application/octet-stream;base64,SGVsbG8="; // echo -n "Hello" | base64 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
374 element.reset(FromDcmtkBridge::FromJson(DICOM_TAG_PATIENT_NAME, a, true, Encoding_Utf8, "")); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
375 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
376 Json::Value b; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
377 std::set<DicomTag> ignoreTagLength; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
378 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short, |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
379 DicomToJsonFlags_Default, 0, Encoding_Ascii, false, ignoreTagLength, 0); |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
380 ASSERT_EQ("Hello", b["0010,0010"].asString()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
381 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
382 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
383 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
384 Json::Value a = Json::arrayValue; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
385 CreateSampleJson(a); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
386 element.reset(FromDcmtkBridge::FromJson(REFERENCED_STUDY_SEQUENCE, a, true, Encoding_Utf8, "")); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
387 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
388 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
389 Json::Value b; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
390 std::set<DicomTag> ignoreTagLength; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
391 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Short, |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
392 DicomToJsonFlags_Default, 0, Encoding_Ascii, false, ignoreTagLength, 0); |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
393 ASSERT_EQ(Json::arrayValue, b["0008,1110"].type()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
394 ASSERT_EQ(2u, b["0008,1110"].size()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
395 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
396 Json::Value::ArrayIndex i = (b["0008,1110"][0]["0010,0010"].asString() == "Hello") ? 0 : 1; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
397 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
398 ASSERT_EQ(3u, b["0008,1110"][i].size()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
399 ASSERT_EQ(2u, b["0008,1110"][1 - i].size()); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
400 ASSERT_EQ(b["0008,1110"][i]["0010,0010"].asString(), "Hello"); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
401 ASSERT_EQ(b["0008,1110"][i]["0010,0020"].asString(), "World"); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
402 ASSERT_EQ(b["0008,1110"][i]["0008,1030"].asString(), "Toto"); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
403 ASSERT_EQ(b["0008,1110"][1 - i]["0010,0010"].asString(), "Hello2"); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
404 ASSERT_EQ(b["0008,1110"][1 - i]["0010,0020"].asString(), "World2"); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
405 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
406 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
407 { |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
408 Json::Value b; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
409 std::set<DicomTag> ignoreTagLength; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
410 FromDcmtkBridge::ElementToJson(b, *element, DicomToJsonFormat_Full, |
4514
5b929e6b3c36
removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4508
diff
changeset
|
411 DicomToJsonFlags_Default, 0, Encoding_Ascii, false, ignoreTagLength, 0); |
4055
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
412 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
413 Json::Value c; |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
414 Toolbox::SimplifyDicomAsJson(c, b, DicomToJsonFormat_Human); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
415 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
416 a[1]["PatientName"] = "Hello2"; // To remove the Data URI Scheme encoding |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
417 ASSERT_EQ(0, c["ReferencedStudySequence"].compare(a)); |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
418 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
419 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
420 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
421 } |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
422 |
9214e3a7b0a2
moving FromDcmtkTests.cpp from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4046
diff
changeset
|
423 |
4059
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
424 TEST(StorageCommitmentReports, Basic) |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
425 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
426 Orthanc::StorageCommitmentReports reports(2); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
427 ASSERT_EQ(2u, reports.GetMaxSize()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
428 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
429 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
430 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "nope"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
431 ASSERT_EQ("nope", accessor.GetTransactionUid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
432 ASSERT_FALSE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
433 ASSERT_THROW(accessor.GetReport(), Orthanc::OrthancException); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
434 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
435 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
436 reports.Store("a", new Orthanc::StorageCommitmentReports::Report("aet_a")); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
437 reports.Store("b", new Orthanc::StorageCommitmentReports::Report("aet_b")); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
438 reports.Store("c", new Orthanc::StorageCommitmentReports::Report("aet_c")); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
439 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
440 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
441 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "a"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
442 ASSERT_FALSE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
443 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
444 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
445 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
446 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "b"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
447 ASSERT_TRUE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
448 ASSERT_EQ("aet_b", accessor.GetReport().GetRemoteAet()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
449 ASSERT_EQ(Orthanc::StorageCommitmentReports::Report::Status_Pending, |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
450 accessor.GetReport().GetStatus()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
451 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
452 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
453 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
454 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "c"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
455 ASSERT_EQ("aet_c", accessor.GetReport().GetRemoteAet()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
456 ASSERT_TRUE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
457 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
458 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
459 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
460 std::unique_ptr<Orthanc::StorageCommitmentReports::Report> report |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
461 (new Orthanc::StorageCommitmentReports::Report("aet")); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
462 report->AddSuccess("class1", "instance1"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
463 report->AddFailure("class2", "instance2", |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
464 Orthanc::StorageCommitmentFailureReason_ReferencedSOPClassNotSupported); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
465 report->MarkAsComplete(); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
466 reports.Store("a", report.release()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
467 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
468 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
469 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
470 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "a"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
471 ASSERT_TRUE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
472 ASSERT_EQ("aet", accessor.GetReport().GetRemoteAet()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
473 ASSERT_EQ(Orthanc::StorageCommitmentReports::Report::Status_Failure, |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
474 accessor.GetReport().GetStatus()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
475 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
476 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
477 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
478 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "b"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
479 ASSERT_FALSE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
480 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
481 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
482 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
483 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "c"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
484 ASSERT_TRUE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
485 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
486 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
487 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
488 std::unique_ptr<Orthanc::StorageCommitmentReports::Report> report |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
489 (new Orthanc::StorageCommitmentReports::Report("aet")); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
490 report->AddSuccess("class1", "instance1"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
491 report->MarkAsComplete(); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
492 reports.Store("a", report.release()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
493 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
494 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
495 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
496 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "a"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
497 ASSERT_TRUE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
498 ASSERT_EQ("aet", accessor.GetReport().GetRemoteAet()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
499 ASSERT_EQ(Orthanc::StorageCommitmentReports::Report::Status_Success, |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
500 accessor.GetReport().GetStatus()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
501 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
502 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
503 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
504 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "b"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
505 ASSERT_FALSE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
506 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
507 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
508 { |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
509 Orthanc::StorageCommitmentReports::Accessor accessor(reports, "c"); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
510 ASSERT_TRUE(accessor.IsValid()); |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
511 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
512 } |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
513 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
514 |
e241e5f3f088
moved LuaTests and MemoryCacheTests from OrthancServer to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4057
diff
changeset
|
515 |
0 | 516 int main(int argc, char **argv) |
517 { | |
1485
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
518 Logging::Initialize(); |
3581
4de1b019ca71
unit test DicomWebJson.PixelSpacing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3561
diff
changeset
|
519 Toolbox::InitializeGlobalLocale(NULL); |
4273
0034f855c023
tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4177
diff
changeset
|
520 SetGlobalVerbosity(Verbosity_Verbose); |
1485
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
521 Toolbox::DetectEndianness(); |
2140 | 522 SystemToolbox::MakeDirectory("UnitTestsResults"); |
1485
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
523 OrthancInitialize(); |
159
c08fbad40ddd
less verbosity in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
524 |
0 | 525 ::testing::InitGoogleTest(&argc, argv); |
526 int result = RUN_ALL_TESTS(); | |
1485
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
527 |
63 | 528 OrthancFinalize(); |
1485
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
529 Logging::Finalize(); |
27661b33f624
Creation of Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1441
diff
changeset
|
530 |
0 | 531 return result; |
532 } |