Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/FrameworkTests.cpp @ 5657:dedbf019a707
Improved parsing of multiple numerical values in DICOM tags
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 06 Jun 2024 17:55:13 +0200 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
3987 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5575
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5575
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5377
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3987 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
10 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
11 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
12 * the License, or (at your option) any later version. |
3987 | 13 * |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
17 * Lesser General Public License for more details. |
3987 | 18 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
19 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
20 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
21 * <http://www.gnu.org/licenses/>. |
3987 | 22 **/ |
23 | |
24 | |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3987
diff
changeset
|
25 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
26 // Must be the first to be sure to use the Orthanc framework shared library |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3992
diff
changeset
|
27 # include <OrthancFramework.h> |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3987
diff
changeset
|
28 #endif |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3987
diff
changeset
|
29 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
30 #if !defined(ORTHANC_ENABLE_PUGIXML) |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
31 # error ORTHANC_ENABLE_PUGIXML is not defined |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
32 #endif |
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
33 |
4045 | 34 #include "../Sources/EnumerationDictionary.h" |
3987 | 35 |
4062 | 36 #include <gtest/gtest.h> |
3987 | 37 |
4045 | 38 #include "../Sources/DicomFormat/DicomTag.h" |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
39 #include "../Sources/HttpServer/HttpToolbox.h" |
4045 | 40 #include "../Sources/Logging.h" |
41 #include "../Sources/OrthancException.h" | |
42 #include "../Sources/Toolbox.h" | |
3987 | 43 |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
44 #if ORTHANC_SANDBOXED != 1 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
45 # include "../Sources/FileBuffer.h" |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
46 # include "../Sources/MetricsRegistry.h" |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
47 # include "../Sources/SystemToolbox.h" |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
48 # include "../Sources/TemporaryFile.h" |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
49 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
50 |
4062 | 51 #include <ctype.h> |
52 | |
3987 | 53 |
54 using namespace Orthanc; | |
55 | |
56 | |
57 TEST(Uuid, Generation) | |
58 { | |
59 for (int i = 0; i < 10; i++) | |
60 { | |
61 std::string s = Toolbox::GenerateUuid(); | |
62 ASSERT_TRUE(Toolbox::IsUuid(s)); | |
63 } | |
64 } | |
65 | |
66 TEST(Uuid, Test) | |
67 { | |
68 ASSERT_FALSE(Toolbox::IsUuid("")); | |
69 ASSERT_FALSE(Toolbox::IsUuid("012345678901234567890123456789012345")); | |
70 ASSERT_TRUE(Toolbox::IsUuid("550e8400-e29b-41d4-a716-446655440000")); | |
71 ASSERT_FALSE(Toolbox::IsUuid("550e8400-e29b-41d4-a716-44665544000_")); | |
72 ASSERT_FALSE(Toolbox::IsUuid("01234567890123456789012345678901234_")); | |
73 ASSERT_FALSE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-44665544000")); | |
74 ASSERT_TRUE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-446655440000")); | |
75 ASSERT_TRUE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-446655440000 ok")); | |
76 ASSERT_FALSE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-446655440000ok")); | |
77 } | |
78 | |
79 TEST(Toolbox, IsSHA1) | |
80 { | |
81 ASSERT_FALSE(Toolbox::IsSHA1("")); | |
82 ASSERT_FALSE(Toolbox::IsSHA1("01234567890123456789012345678901234567890123")); | |
83 ASSERT_FALSE(Toolbox::IsSHA1("012345678901234567890123456789012345678901234")); | |
84 ASSERT_TRUE(Toolbox::IsSHA1("b5ed549f-956400ce-69a8c063-bf5b78be-2732a4b9")); | |
85 | |
86 std::string sha = " b5ed549f-956400ce-69a8c063-bf5b78be-2732a4b9 "; | |
87 ASSERT_TRUE(Toolbox::IsSHA1(sha)); | |
88 sha[3] = '\0'; | |
89 sha[53] = '\0'; | |
90 ASSERT_TRUE(Toolbox::IsSHA1(sha)); | |
91 sha[40] = '\0'; | |
92 ASSERT_FALSE(Toolbox::IsSHA1(sha)); | |
93 ASSERT_FALSE(Toolbox::IsSHA1(" ")); | |
94 | |
95 ASSERT_TRUE(Toolbox::IsSHA1("16738bc3-e47ed42a-43ce044c-a3414a45-cb069bd0")); | |
96 | |
97 std::string s; | |
98 Toolbox::ComputeSHA1(s, "The quick brown fox jumps over the lazy dog"); | |
99 ASSERT_TRUE(Toolbox::IsSHA1(s)); | |
100 ASSERT_EQ("2fd4e1c6-7a2d28fc-ed849ee1-bb76e739-1b93eb12", s); | |
101 | |
102 ASSERT_FALSE(Toolbox::IsSHA1("b5ed549f-956400ce-69a8c063-bf5b78be-2732a4b_")); | |
103 } | |
104 | |
105 | |
106 TEST(ParseGetArguments, Basic) | |
107 { | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
108 HttpToolbox::GetArguments b; |
3987 | 109 HttpToolbox::ParseGetArguments(b, "aaa=baaa&bb=a&aa=c"); |
110 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
111 HttpToolbox::Arguments a; |
3987 | 112 HttpToolbox::CompileGetArguments(a, b); |
113 | |
114 ASSERT_EQ(3u, a.size()); | |
115 ASSERT_EQ(a["aaa"], "baaa"); | |
116 ASSERT_EQ(a["bb"], "a"); | |
117 ASSERT_EQ(a["aa"], "c"); | |
118 } | |
119 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
120 |
3987 | 121 TEST(ParseGetArguments, BasicEmpty) |
122 { | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
123 HttpToolbox::GetArguments b; |
3987 | 124 HttpToolbox::ParseGetArguments(b, "aaa&bb=aa&aa"); |
125 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
126 HttpToolbox::Arguments a; |
3987 | 127 HttpToolbox::CompileGetArguments(a, b); |
128 | |
129 ASSERT_EQ(3u, a.size()); | |
130 ASSERT_EQ(a["aaa"], ""); | |
131 ASSERT_EQ(a["bb"], "aa"); | |
132 ASSERT_EQ(a["aa"], ""); | |
133 } | |
134 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
135 |
3987 | 136 TEST(ParseGetArguments, Single) |
137 { | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
138 HttpToolbox::GetArguments b; |
3987 | 139 HttpToolbox::ParseGetArguments(b, "aaa=baaa"); |
140 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
141 HttpToolbox::Arguments a; |
3987 | 142 HttpToolbox::CompileGetArguments(a, b); |
143 | |
144 ASSERT_EQ(1u, a.size()); | |
145 ASSERT_EQ(a["aaa"], "baaa"); | |
146 } | |
147 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
148 |
3987 | 149 TEST(ParseGetArguments, SingleEmpty) |
150 { | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
151 HttpToolbox::GetArguments b; |
3987 | 152 HttpToolbox::ParseGetArguments(b, "aaa"); |
153 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
154 HttpToolbox::Arguments a; |
3987 | 155 HttpToolbox::CompileGetArguments(a, b); |
156 | |
157 ASSERT_EQ(1u, a.size()); | |
158 ASSERT_EQ(a["aaa"], ""); | |
159 } | |
160 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
161 |
3987 | 162 TEST(ParseGetQuery, Test1) |
163 { | |
164 UriComponents uri; | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
165 HttpToolbox::GetArguments b; |
3987 | 166 HttpToolbox::ParseGetQuery(uri, b, "/instances/test/world?aaa=baaa&bb=a&aa=c"); |
167 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
168 HttpToolbox::Arguments a; |
3987 | 169 HttpToolbox::CompileGetArguments(a, b); |
170 | |
171 ASSERT_EQ(3u, uri.size()); | |
172 ASSERT_EQ("instances", uri[0]); | |
173 ASSERT_EQ("test", uri[1]); | |
174 ASSERT_EQ("world", uri[2]); | |
175 ASSERT_EQ(3u, a.size()); | |
176 ASSERT_EQ(a["aaa"], "baaa"); | |
177 ASSERT_EQ(a["bb"], "a"); | |
178 ASSERT_EQ(a["aa"], "c"); | |
179 } | |
180 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
181 |
3987 | 182 TEST(ParseGetQuery, Test2) |
183 { | |
184 UriComponents uri; | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
185 HttpToolbox::GetArguments b; |
3987 | 186 HttpToolbox::ParseGetQuery(uri, b, "/instances/test/world"); |
187 | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
188 HttpToolbox::Arguments a; |
3987 | 189 HttpToolbox::CompileGetArguments(a, b); |
190 | |
191 ASSERT_EQ(3u, uri.size()); | |
192 ASSERT_EQ("instances", uri[0]); | |
193 ASSERT_EQ("test", uri[1]); | |
194 ASSERT_EQ("world", uri[2]); | |
195 ASSERT_EQ(0u, a.size()); | |
196 } | |
4330
a01b1c9cbef4
moving generic type definitions from IHttpHandler to HttpToolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4327
diff
changeset
|
197 |
3987 | 198 |
199 TEST(Uri, SplitUriComponents) | |
200 { | |
201 UriComponents c, d; | |
202 Toolbox::SplitUriComponents(c, "/cou/hello/world"); | |
203 ASSERT_EQ(3u, c.size()); | |
204 ASSERT_EQ("cou", c[0]); | |
205 ASSERT_EQ("hello", c[1]); | |
206 ASSERT_EQ("world", c[2]); | |
207 | |
208 Toolbox::SplitUriComponents(c, "/cou/hello/world/"); | |
209 ASSERT_EQ(3u, c.size()); | |
210 ASSERT_EQ("cou", c[0]); | |
211 ASSERT_EQ("hello", c[1]); | |
212 ASSERT_EQ("world", c[2]); | |
213 | |
214 Toolbox::SplitUriComponents(c, "/cou/hello/world/a"); | |
215 ASSERT_EQ(4u, c.size()); | |
216 ASSERT_EQ("cou", c[0]); | |
217 ASSERT_EQ("hello", c[1]); | |
218 ASSERT_EQ("world", c[2]); | |
219 ASSERT_EQ("a", c[3]); | |
220 | |
221 Toolbox::SplitUriComponents(c, "/"); | |
222 ASSERT_EQ(0u, c.size()); | |
223 | |
224 Toolbox::SplitUriComponents(c, "/hello"); | |
225 ASSERT_EQ(1u, c.size()); | |
226 ASSERT_EQ("hello", c[0]); | |
227 | |
228 Toolbox::SplitUriComponents(c, "/hello/"); | |
229 ASSERT_EQ(1u, c.size()); | |
230 ASSERT_EQ("hello", c[0]); | |
231 | |
232 ASSERT_THROW(Toolbox::SplitUriComponents(c, ""), OrthancException); | |
233 ASSERT_THROW(Toolbox::SplitUriComponents(c, "a"), OrthancException); | |
234 ASSERT_THROW(Toolbox::SplitUriComponents(c, "/coucou//coucou"), OrthancException); | |
235 | |
236 c.clear(); | |
237 c.push_back("test"); | |
238 ASSERT_EQ("/", Toolbox::FlattenUri(c, 10)); | |
239 } | |
240 | |
241 | |
242 TEST(Uri, Truncate) | |
243 { | |
244 UriComponents c, d; | |
245 Toolbox::SplitUriComponents(c, "/cou/hello/world"); | |
246 | |
247 Toolbox::TruncateUri(d, c, 0); | |
248 ASSERT_EQ(3u, d.size()); | |
249 ASSERT_EQ("cou", d[0]); | |
250 ASSERT_EQ("hello", d[1]); | |
251 ASSERT_EQ("world", d[2]); | |
252 | |
253 Toolbox::TruncateUri(d, c, 1); | |
254 ASSERT_EQ(2u, d.size()); | |
255 ASSERT_EQ("hello", d[0]); | |
256 ASSERT_EQ("world", d[1]); | |
257 | |
258 Toolbox::TruncateUri(d, c, 2); | |
259 ASSERT_EQ(1u, d.size()); | |
260 ASSERT_EQ("world", d[0]); | |
261 | |
262 Toolbox::TruncateUri(d, c, 3); | |
263 ASSERT_EQ(0u, d.size()); | |
264 | |
265 Toolbox::TruncateUri(d, c, 4); | |
266 ASSERT_EQ(0u, d.size()); | |
267 | |
268 Toolbox::TruncateUri(d, c, 5); | |
269 ASSERT_EQ(0u, d.size()); | |
270 } | |
271 | |
272 | |
273 TEST(Uri, Child) | |
274 { | |
275 UriComponents c1; Toolbox::SplitUriComponents(c1, "/hello/world"); | |
276 UriComponents c2; Toolbox::SplitUriComponents(c2, "/hello/hello"); | |
277 UriComponents c3; Toolbox::SplitUriComponents(c3, "/hello"); | |
278 UriComponents c4; Toolbox::SplitUriComponents(c4, "/world"); | |
279 UriComponents c5; Toolbox::SplitUriComponents(c5, "/"); | |
280 | |
281 ASSERT_TRUE(Toolbox::IsChildUri(c1, c1)); | |
282 ASSERT_FALSE(Toolbox::IsChildUri(c1, c2)); | |
283 ASSERT_FALSE(Toolbox::IsChildUri(c1, c3)); | |
284 ASSERT_FALSE(Toolbox::IsChildUri(c1, c4)); | |
285 ASSERT_FALSE(Toolbox::IsChildUri(c1, c5)); | |
286 | |
287 ASSERT_FALSE(Toolbox::IsChildUri(c2, c1)); | |
288 ASSERT_TRUE(Toolbox::IsChildUri(c2, c2)); | |
289 ASSERT_FALSE(Toolbox::IsChildUri(c2, c3)); | |
290 ASSERT_FALSE(Toolbox::IsChildUri(c2, c4)); | |
291 ASSERT_FALSE(Toolbox::IsChildUri(c2, c5)); | |
292 | |
293 ASSERT_TRUE(Toolbox::IsChildUri(c3, c1)); | |
294 ASSERT_TRUE(Toolbox::IsChildUri(c3, c2)); | |
295 ASSERT_TRUE(Toolbox::IsChildUri(c3, c3)); | |
296 ASSERT_FALSE(Toolbox::IsChildUri(c3, c4)); | |
297 ASSERT_FALSE(Toolbox::IsChildUri(c3, c5)); | |
298 | |
299 ASSERT_FALSE(Toolbox::IsChildUri(c4, c1)); | |
300 ASSERT_FALSE(Toolbox::IsChildUri(c4, c2)); | |
301 ASSERT_FALSE(Toolbox::IsChildUri(c4, c3)); | |
302 ASSERT_TRUE(Toolbox::IsChildUri(c4, c4)); | |
303 ASSERT_FALSE(Toolbox::IsChildUri(c4, c5)); | |
304 | |
305 ASSERT_TRUE(Toolbox::IsChildUri(c5, c1)); | |
306 ASSERT_TRUE(Toolbox::IsChildUri(c5, c2)); | |
307 ASSERT_TRUE(Toolbox::IsChildUri(c5, c3)); | |
308 ASSERT_TRUE(Toolbox::IsChildUri(c5, c4)); | |
309 ASSERT_TRUE(Toolbox::IsChildUri(c5, c5)); | |
310 } | |
311 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
312 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
313 #if ORTHANC_SANDBOXED != 1 |
3987 | 314 TEST(Uri, AutodetectMimeType) |
315 { | |
316 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("../NOTES")); | |
317 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("")); | |
318 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("/")); | |
319 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("a/a")); | |
320 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("..\\a\\")); | |
321 ASSERT_EQ(MimeType_Binary, SystemToolbox::AutodetectMimeType("..\\a\\a")); | |
322 | |
323 ASSERT_EQ(MimeType_PlainText, SystemToolbox::AutodetectMimeType("../NOTES.txt")); | |
324 ASSERT_EQ(MimeType_PlainText, SystemToolbox::AutodetectMimeType("../coucou.xml/NOTES.txt")); | |
325 ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("..\\coucou.\\NOTES.xml")); | |
326 ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("../.xml")); | |
327 ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("../.XmL")); | |
328 | |
329 ASSERT_EQ(MimeType_JavaScript, SystemToolbox::AutodetectMimeType("NOTES.js")); | |
330 ASSERT_EQ(MimeType_Json, SystemToolbox::AutodetectMimeType("NOTES.json")); | |
331 ASSERT_EQ(MimeType_Pdf, SystemToolbox::AutodetectMimeType("NOTES.pdf")); | |
332 ASSERT_EQ(MimeType_Css, SystemToolbox::AutodetectMimeType("NOTES.css")); | |
333 ASSERT_EQ(MimeType_Html, SystemToolbox::AutodetectMimeType("NOTES.html")); | |
334 ASSERT_EQ(MimeType_PlainText, SystemToolbox::AutodetectMimeType("NOTES.txt")); | |
335 ASSERT_EQ(MimeType_Xml, SystemToolbox::AutodetectMimeType("NOTES.xml")); | |
336 ASSERT_EQ(MimeType_Gif, SystemToolbox::AutodetectMimeType("NOTES.gif")); | |
337 ASSERT_EQ(MimeType_Jpeg, SystemToolbox::AutodetectMimeType("NOTES.jpg")); | |
338 ASSERT_EQ(MimeType_Jpeg, SystemToolbox::AutodetectMimeType("NOTES.jpeg")); | |
339 ASSERT_EQ(MimeType_Png, SystemToolbox::AutodetectMimeType("NOTES.png")); | |
340 ASSERT_EQ(MimeType_NaCl, SystemToolbox::AutodetectMimeType("NOTES.nexe")); | |
341 ASSERT_EQ(MimeType_Json, SystemToolbox::AutodetectMimeType("NOTES.nmf")); | |
342 ASSERT_EQ(MimeType_PNaCl, SystemToolbox::AutodetectMimeType("NOTES.pexe")); | |
343 ASSERT_EQ(MimeType_Svg, SystemToolbox::AutodetectMimeType("NOTES.svg")); | |
344 ASSERT_EQ(MimeType_Woff, SystemToolbox::AutodetectMimeType("NOTES.woff")); | |
345 ASSERT_EQ(MimeType_Woff2, SystemToolbox::AutodetectMimeType("NOTES.woff2")); | |
4887 | 346 ASSERT_EQ(MimeType_Ico, SystemToolbox::AutodetectMimeType("NOTES.ico")); |
3987 | 347 |
348 // Test primitives from the "RegisterDefaultExtensions()" that was | |
349 // present in the sample "Serve Folders plugin" of Orthanc 1.4.2 | |
350 ASSERT_STREQ("application/javascript", EnumerationToString(SystemToolbox::AutodetectMimeType(".js"))); | |
351 ASSERT_STREQ("application/json", EnumerationToString(SystemToolbox::AutodetectMimeType(".json"))); | |
352 ASSERT_STREQ("application/json", EnumerationToString(SystemToolbox::AutodetectMimeType(".nmf"))); | |
353 ASSERT_STREQ("application/octet-stream", EnumerationToString(SystemToolbox::AutodetectMimeType(""))); | |
354 ASSERT_STREQ("application/wasm", EnumerationToString(SystemToolbox::AutodetectMimeType(".wasm"))); | |
355 ASSERT_STREQ("application/x-font-woff", EnumerationToString(SystemToolbox::AutodetectMimeType(".woff"))); | |
356 ASSERT_STREQ("application/x-nacl", EnumerationToString(SystemToolbox::AutodetectMimeType(".nexe"))); | |
357 ASSERT_STREQ("application/x-pnacl", EnumerationToString(SystemToolbox::AutodetectMimeType(".pexe"))); | |
358 ASSERT_STREQ("application/xml", EnumerationToString(SystemToolbox::AutodetectMimeType(".xml"))); | |
359 ASSERT_STREQ("font/woff2", EnumerationToString(SystemToolbox::AutodetectMimeType(".woff2"))); | |
360 ASSERT_STREQ("image/gif", EnumerationToString(SystemToolbox::AutodetectMimeType(".gif"))); | |
361 ASSERT_STREQ("image/jpeg", EnumerationToString(SystemToolbox::AutodetectMimeType(".jpeg"))); | |
362 ASSERT_STREQ("image/jpeg", EnumerationToString(SystemToolbox::AutodetectMimeType(".jpg"))); | |
363 ASSERT_STREQ("image/png", EnumerationToString(SystemToolbox::AutodetectMimeType(".png"))); | |
364 ASSERT_STREQ("image/svg+xml", EnumerationToString(SystemToolbox::AutodetectMimeType(".svg"))); | |
365 ASSERT_STREQ("text/css", EnumerationToString(SystemToolbox::AutodetectMimeType(".css"))); | |
366 ASSERT_STREQ("text/html", EnumerationToString(SystemToolbox::AutodetectMimeType(".html"))); | |
5348
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5337
diff
changeset
|
367 |
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5337
diff
changeset
|
368 ASSERT_STREQ("model/obj", EnumerationToString(SystemToolbox::AutodetectMimeType(".obj"))); |
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5337
diff
changeset
|
369 ASSERT_STREQ("model/mtl", EnumerationToString(SystemToolbox::AutodetectMimeType(".mtl"))); |
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5337
diff
changeset
|
370 ASSERT_STREQ("model/stl", EnumerationToString(SystemToolbox::AutodetectMimeType(".stl"))); |
3987 | 371 } |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
372 #endif |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
373 |
3987 | 374 |
375 TEST(Toolbox, ComputeMD5) | |
376 { | |
377 std::string s; | |
378 | |
379 // # echo -n "Hello" | md5sum | |
380 | |
381 Toolbox::ComputeMD5(s, "Hello"); | |
382 ASSERT_EQ("8b1a9953c4611296a827abf8c47804d7", s); | |
383 Toolbox::ComputeMD5(s, ""); | |
384 ASSERT_EQ("d41d8cd98f00b204e9800998ecf8427e", s); | |
5377 | 385 |
386 Toolbox::ComputeMD5(s, "aaabbbccc"); | |
387 ASSERT_EQ("d1aaf4767a3c10a473407a4e47b02da6", s); | |
388 | |
389 std::set<std::string> set; | |
390 | |
391 Toolbox::ComputeMD5(s, set); | |
392 ASSERT_EQ("d41d8cd98f00b204e9800998ecf8427e", s); // empty set same as empty string | |
393 | |
394 set.insert("bbb"); | |
395 set.insert("ccc"); | |
396 set.insert("aaa"); | |
397 | |
398 Toolbox::ComputeMD5(s, set); | |
399 ASSERT_EQ("d1aaf4767a3c10a473407a4e47b02da6", s); // set md5 same as string with the values sorted | |
3987 | 400 } |
401 | |
402 TEST(Toolbox, ComputeSHA1) | |
403 { | |
404 std::string s; | |
405 | |
406 Toolbox::ComputeSHA1(s, "The quick brown fox jumps over the lazy dog"); | |
407 ASSERT_EQ("2fd4e1c6-7a2d28fc-ed849ee1-bb76e739-1b93eb12", s); | |
408 Toolbox::ComputeSHA1(s, ""); | |
409 ASSERT_EQ("da39a3ee-5e6b4b0d-3255bfef-95601890-afd80709", s); | |
410 } | |
411 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
412 #if ORTHANC_SANDBOXED != 1 |
3987 | 413 TEST(Toolbox, PathToExecutable) |
414 { | |
415 printf("[%s]\n", SystemToolbox::GetPathToExecutable().c_str()); | |
416 printf("[%s]\n", SystemToolbox::GetDirectoryOfExecutable().c_str()); | |
417 } | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
418 #endif |
3987 | 419 |
420 TEST(Toolbox, StripSpaces) | |
421 { | |
422 ASSERT_EQ("", Toolbox::StripSpaces(" \t \r \n ")); | |
423 ASSERT_EQ("coucou", Toolbox::StripSpaces(" coucou \t \r \n ")); | |
424 ASSERT_EQ("cou cou", Toolbox::StripSpaces(" cou cou \n ")); | |
425 ASSERT_EQ("c", Toolbox::StripSpaces(" \n\t c\r \n ")); | |
4622
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
426 |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
427 std::string s = "\" abd \""; |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
428 Toolbox::RemoveSurroundingQuotes(s); ASSERT_EQ(" abd ", s); |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
429 |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
430 s = " \" abd \" "; |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
431 Toolbox::RemoveSurroundingQuotes(s); ASSERT_EQ(" \" abd \" ", s); |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
432 |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
433 s = Toolbox::StripSpaces(s); |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
434 Toolbox::RemoveSurroundingQuotes(s); ASSERT_EQ(" abd ", s); |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
435 |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
436 s = "\""; |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
437 Toolbox::RemoveSurroundingQuotes(s); ASSERT_EQ("", s); |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
438 |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
439 s = "\"\""; |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
440 Toolbox::RemoveSurroundingQuotes(s); ASSERT_EQ("", s); |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
441 |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
442 s = "\"_\""; |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
443 Toolbox::RemoveSurroundingQuotes(s); ASSERT_EQ("_", s); |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
444 |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
445 s = "\"\"\""; |
9086aeb9d9d2
RestApiCallDocumentation::SetAnswerHeader() and Toolbox::RemoveSurroundingQuotes()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4538
diff
changeset
|
446 Toolbox::RemoveSurroundingQuotes(s); ASSERT_EQ("\"", s); |
3987 | 447 } |
448 | |
449 TEST(Toolbox, Case) | |
450 { | |
451 std::string s = "CoU"; | |
452 std::string ss; | |
453 | |
454 Toolbox::ToUpperCase(ss, s); | |
455 ASSERT_EQ("COU", ss); | |
456 Toolbox::ToLowerCase(ss, s); | |
457 ASSERT_EQ("cou", ss); | |
458 | |
459 s = "CoU"; | |
460 Toolbox::ToUpperCase(s); | |
461 ASSERT_EQ("COU", s); | |
462 | |
463 s = "CoU"; | |
464 Toolbox::ToLowerCase(s); | |
465 ASSERT_EQ("cou", s); | |
466 } | |
467 | |
468 | |
469 TEST(Logger, Basic) | |
470 { | |
471 LOG(INFO) << "I say hello"; | |
472 } | |
473 | |
474 TEST(Toolbox, ConvertFromLatin1) | |
475 { | |
476 // This is a Latin-1 test string | |
477 const unsigned char data[10] = { 0xe0, 0xe9, 0xea, 0xe7, 0x26, 0xc6, 0x61, 0x62, 0x63, 0x00 }; | |
478 | |
479 std::string s((char*) &data[0], 10); | |
480 ASSERT_EQ("&abc", Toolbox::ConvertToAscii(s)); | |
481 | |
482 // Open in Emacs, then save with UTF-8 encoding, then "hexdump -C" | |
483 std::string utf8 = Toolbox::ConvertToUtf8(s, Encoding_Latin1, false); | |
484 ASSERT_EQ(15u, utf8.size()); | |
485 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[0])); | |
486 ASSERT_EQ(0xa0, static_cast<unsigned char>(utf8[1])); | |
487 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[2])); | |
488 ASSERT_EQ(0xa9, static_cast<unsigned char>(utf8[3])); | |
489 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[4])); | |
490 ASSERT_EQ(0xaa, static_cast<unsigned char>(utf8[5])); | |
491 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[6])); | |
492 ASSERT_EQ(0xa7, static_cast<unsigned char>(utf8[7])); | |
493 ASSERT_EQ(0x26, static_cast<unsigned char>(utf8[8])); | |
494 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[9])); | |
495 ASSERT_EQ(0x86, static_cast<unsigned char>(utf8[10])); | |
496 ASSERT_EQ(0x61, static_cast<unsigned char>(utf8[11])); | |
497 ASSERT_EQ(0x62, static_cast<unsigned char>(utf8[12])); | |
498 ASSERT_EQ(0x63, static_cast<unsigned char>(utf8[13])); | |
499 ASSERT_EQ(0x00, static_cast<unsigned char>(utf8[14])); // Null-terminated string | |
500 } | |
501 | |
502 | |
503 TEST(Toolbox, FixUtf8) | |
504 { | |
505 // This is a Latin-1 test string: "crane" with a circumflex accent | |
506 const unsigned char latin1[] = { 0x63, 0x72, 0xe2, 0x6e, 0x65 }; | |
507 | |
508 std::string s((char*) &latin1[0], sizeof(latin1) / sizeof(char)); | |
509 | |
510 ASSERT_EQ(s, Toolbox::ConvertFromUtf8(Toolbox::ConvertToUtf8(s, Encoding_Latin1, false), Encoding_Latin1)); | |
511 ASSERT_EQ("cre", Toolbox::ConvertToUtf8(s, Encoding_Utf8, false)); | |
512 } | |
513 | |
514 | |
515 static int32_t GetUnicode(const uint8_t* data, | |
516 size_t size, | |
517 size_t expectedLength) | |
518 { | |
519 std::string s((char*) &data[0], size); | |
520 uint32_t unicode; | |
521 size_t length; | |
522 Toolbox::Utf8ToUnicodeCharacter(unicode, length, s, 0); | |
523 if (length != expectedLength) | |
524 { | |
525 return -1; // Error case | |
526 } | |
527 else | |
528 { | |
529 return unicode; | |
530 } | |
531 } | |
532 | |
533 | |
534 TEST(Toolbox, Utf8ToUnicode) | |
535 { | |
536 // https://en.wikipedia.org/wiki/UTF-8 | |
537 | |
538 ASSERT_EQ(1u, sizeof(char)); | |
539 ASSERT_EQ(1u, sizeof(uint8_t)); | |
540 | |
541 { | |
542 const uint8_t data[] = { 0x24 }; | |
543 ASSERT_EQ(0x24, GetUnicode(data, 1, 1)); | |
544 ASSERT_THROW(GetUnicode(data, 0, 1), OrthancException); | |
545 } | |
546 | |
547 { | |
548 const uint8_t data[] = { 0xc2, 0xa2 }; | |
549 ASSERT_EQ(0xa2, GetUnicode(data, 2, 2)); | |
550 ASSERT_THROW(GetUnicode(data, 1, 2), OrthancException); | |
551 } | |
552 | |
553 { | |
554 const uint8_t data[] = { 0xe0, 0xa4, 0xb9 }; | |
555 ASSERT_EQ(0x0939, GetUnicode(data, 3, 3)); | |
556 ASSERT_THROW(GetUnicode(data, 2, 3), OrthancException); | |
557 } | |
558 | |
559 { | |
560 const uint8_t data[] = { 0xe2, 0x82, 0xac }; | |
561 ASSERT_EQ(0x20ac, GetUnicode(data, 3, 3)); | |
562 ASSERT_THROW(GetUnicode(data, 2, 3), OrthancException); | |
563 } | |
564 | |
565 { | |
566 const uint8_t data[] = { 0xf0, 0x90, 0x8d, 0x88 }; | |
567 ASSERT_EQ(0x010348, GetUnicode(data, 4, 4)); | |
568 ASSERT_THROW(GetUnicode(data, 3, 4), OrthancException); | |
569 } | |
570 | |
571 { | |
572 const uint8_t data[] = { 0xe0 }; | |
573 ASSERT_THROW(GetUnicode(data, 1, 1), OrthancException); | |
574 } | |
575 } | |
576 | |
577 | |
578 TEST(Toolbox, UrlDecode) | |
579 { | |
580 std::string s; | |
581 | |
582 s = "Hello%20World"; | |
583 Toolbox::UrlDecode(s); | |
584 ASSERT_EQ("Hello World", s); | |
585 | |
586 s = "%21%23%24%26%27%28%29%2A%2B%2c%2f%3A%3b%3d%3f%40%5B%5D%90%ff"; | |
587 Toolbox::UrlDecode(s); | |
588 std::string ss = "!#$&'()*+,/:;=?@[]"; | |
589 ss.push_back((char) 144); | |
590 ss.push_back((char) 255); | |
591 ASSERT_EQ(ss, s); | |
592 | |
593 s = "(2000%2C00A4)+Other"; | |
594 Toolbox::UrlDecode(s); | |
595 ASSERT_EQ("(2000,00A4) Other", s); | |
596 } | |
597 | |
598 | |
599 TEST(Toolbox, IsAsciiString) | |
600 { | |
601 std::string s = "Hello 12 /"; | |
602 ASSERT_EQ(10u, s.size()); | |
603 ASSERT_TRUE(Toolbox::IsAsciiString(s)); | |
604 ASSERT_TRUE(Toolbox::IsAsciiString(s.c_str(), 10)); | |
605 ASSERT_FALSE(Toolbox::IsAsciiString(s.c_str(), 11)); // Taking the trailing hidden '\0' | |
606 | |
607 s[2] = '\0'; | |
608 ASSERT_EQ(10u, s.size()); | |
609 ASSERT_FALSE(Toolbox::IsAsciiString(s)); | |
610 | |
611 ASSERT_TRUE(Toolbox::IsAsciiString("Hello\nworld")); | |
612 ASSERT_FALSE(Toolbox::IsAsciiString("Hello\rworld")); | |
613 | |
614 ASSERT_EQ("Hello\nworld", Toolbox::ConvertToAscii("Hello\nworld")); | |
615 ASSERT_EQ("Helloworld", Toolbox::ConvertToAscii("Hello\r\tworld")); | |
616 } | |
617 | |
618 | |
619 #if defined(__linux__) | |
620 TEST(Toolbox, AbsoluteDirectory) | |
621 { | |
622 ASSERT_EQ("/tmp/hello", SystemToolbox::InterpretRelativePath("/tmp", "hello")); | |
623 ASSERT_EQ("/tmp", SystemToolbox::InterpretRelativePath("/tmp", "/tmp")); | |
624 } | |
625 #endif | |
626 | |
627 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
628 #if ORTHANC_SANDBOXED != 1 |
3987 | 629 TEST(Toolbox, WriteFile) |
630 { | |
631 std::string path; | |
632 | |
633 { | |
634 TemporaryFile tmp; | |
635 path = tmp.GetPath(); | |
636 | |
637 std::string s; | |
638 s.append("Hello"); | |
639 s.push_back('\0'); | |
640 s.append("World"); | |
641 ASSERT_EQ(11u, s.size()); | |
642 | |
643 SystemToolbox::WriteFile(s, path.c_str()); | |
644 | |
645 std::string t; | |
646 SystemToolbox::ReadFile(t, path.c_str()); | |
647 | |
648 ASSERT_EQ(11u, t.size()); | |
649 ASSERT_EQ(0, t[5]); | |
650 ASSERT_EQ(0, memcmp(s.c_str(), t.c_str(), s.size())); | |
651 | |
652 std::string h; | |
653 ASSERT_EQ(true, SystemToolbox::ReadHeader(h, path.c_str(), 1)); | |
654 ASSERT_EQ(1u, h.size()); | |
655 ASSERT_EQ('H', h[0]); | |
656 ASSERT_TRUE(SystemToolbox::ReadHeader(h, path.c_str(), 0)); | |
657 ASSERT_EQ(0u, h.size()); | |
658 ASSERT_FALSE(SystemToolbox::ReadHeader(h, path.c_str(), 32)); | |
659 ASSERT_EQ(11u, h.size()); | |
660 ASSERT_EQ(0, memcmp(s.c_str(), h.c_str(), s.size())); | |
661 } | |
662 | |
663 std::string u; | |
664 ASSERT_THROW(SystemToolbox::ReadFile(u, path.c_str()), OrthancException); | |
4186 | 665 |
666 { | |
667 TemporaryFile tmp; | |
668 std::string s = "Hello"; | |
669 SystemToolbox::WriteFile(s, tmp.GetPath(), true /* call fsync() */); | |
670 std::string t; | |
671 SystemToolbox::ReadFile(t, tmp.GetPath()); | |
672 ASSERT_EQ(s, t); | |
673 } | |
3987 | 674 } |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
675 #endif |
3987 | 676 |
677 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
678 #if ORTHANC_SANDBOXED != 1 |
3987 | 679 TEST(Toolbox, FileBuffer) |
680 { | |
681 FileBuffer f; | |
682 f.Append("a", 1); | |
683 f.Append("", 0); | |
684 f.Append("bc", 2); | |
685 | |
686 std::string s; | |
687 f.Read(s); | |
688 ASSERT_EQ("abc", s); | |
689 | |
690 ASSERT_THROW(f.Append("d", 1), OrthancException); // File is closed | |
691 } | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
692 #endif |
3987 | 693 |
694 | |
695 TEST(Toolbox, Wildcard) | |
696 { | |
697 ASSERT_EQ("abcd", Toolbox::WildcardToRegularExpression("abcd")); | |
698 ASSERT_EQ("ab.*cd", Toolbox::WildcardToRegularExpression("ab*cd")); | |
699 ASSERT_EQ("ab..cd", Toolbox::WildcardToRegularExpression("ab??cd")); | |
700 ASSERT_EQ("a.*b.c.*d", Toolbox::WildcardToRegularExpression("a*b?c*d")); | |
701 ASSERT_EQ("a\\{b\\]", Toolbox::WildcardToRegularExpression("a{b]")); | |
702 } | |
703 | |
704 | |
705 TEST(Toolbox, Tokenize) | |
706 { | |
707 std::vector<std::string> t; | |
708 | |
709 Toolbox::TokenizeString(t, "", ','); | |
710 ASSERT_EQ(1u, t.size()); | |
711 ASSERT_EQ("", t[0]); | |
712 | |
713 Toolbox::TokenizeString(t, "abc", ','); | |
714 ASSERT_EQ(1u, t.size()); | |
715 ASSERT_EQ("abc", t[0]); | |
716 | |
717 Toolbox::TokenizeString(t, "ab,cd,ef,", ','); | |
718 ASSERT_EQ(4u, t.size()); | |
719 ASSERT_EQ("ab", t[0]); | |
720 ASSERT_EQ("cd", t[1]); | |
721 ASSERT_EQ("ef", t[2]); | |
722 ASSERT_EQ("", t[3]); | |
723 } | |
724 | |
5373 | 725 TEST(Toolbox, SplitString) |
726 { | |
727 { | |
728 std::set<std::string> result; | |
729 Toolbox::SplitString(result, "", ';'); | |
730 ASSERT_EQ(0u, result.size()); | |
731 } | |
732 | |
733 { | |
734 std::set<std::string> result; | |
735 Toolbox::SplitString(result, "a", ';'); | |
736 ASSERT_EQ(1u, result.size()); | |
737 ASSERT_TRUE(result.end() != result.find("a")); | |
738 } | |
739 | |
740 { | |
741 std::set<std::string> result; | |
742 Toolbox::SplitString(result, "a;b", ';'); | |
743 ASSERT_EQ(2u, result.size()); | |
744 ASSERT_TRUE(result.end() != result.find("a")); | |
745 ASSERT_TRUE(result.end() != result.find("b")); | |
746 } | |
747 | |
748 { | |
749 std::set<std::string> result; | |
750 Toolbox::SplitString(result, "a;b;", ';'); | |
751 ASSERT_EQ(2u, result.size()); | |
752 ASSERT_TRUE(result.end() != result.find("a")); | |
753 ASSERT_TRUE(result.end() != result.find("b")); | |
754 } | |
755 | |
756 { | |
757 std::set<std::string> result; | |
758 Toolbox::SplitString(result, "a;a", ';'); | |
759 ASSERT_EQ(1u, result.size()); | |
760 ASSERT_TRUE(result.end() != result.find("a")); | |
761 } | |
762 | |
763 { | |
764 std::vector<std::string> result; | |
765 Toolbox::SplitString(result, "", ';'); | |
766 ASSERT_EQ(0u, result.size()); | |
767 } | |
768 | |
769 { | |
770 std::vector<std::string> result; | |
771 Toolbox::SplitString(result, "a", ';'); | |
772 ASSERT_EQ(1u, result.size()); | |
773 ASSERT_EQ("a", result[0]); | |
774 } | |
775 | |
776 { | |
777 std::vector<std::string> result; | |
778 Toolbox::SplitString(result, "a;b", ';'); | |
779 ASSERT_EQ(2u, result.size()); | |
780 ASSERT_EQ("a", result[0]); | |
781 ASSERT_EQ("b", result[1]); | |
782 } | |
783 | |
784 { | |
785 std::vector<std::string> result; | |
786 Toolbox::SplitString(result, "a;b;", ';'); | |
787 ASSERT_EQ(2u, result.size()); | |
788 ASSERT_EQ("a", result[0]); | |
789 ASSERT_EQ("b", result[1]); | |
790 } | |
791 | |
792 { | |
793 std::vector<std::string> result; | |
794 Toolbox::TokenizeString(result, "a;a", ';'); | |
795 ASSERT_EQ(2u, result.size()); | |
796 ASSERT_EQ("a", result[0]); | |
797 ASSERT_EQ("a", result[1]); | |
798 } | |
799 } | |
800 | |
3987 | 801 TEST(Toolbox, Enumerations) |
802 { | |
803 ASSERT_EQ(Encoding_Utf8, StringToEncoding(EnumerationToString(Encoding_Utf8))); | |
804 ASSERT_EQ(Encoding_Ascii, StringToEncoding(EnumerationToString(Encoding_Ascii))); | |
805 ASSERT_EQ(Encoding_Latin1, StringToEncoding(EnumerationToString(Encoding_Latin1))); | |
806 ASSERT_EQ(Encoding_Latin2, StringToEncoding(EnumerationToString(Encoding_Latin2))); | |
807 ASSERT_EQ(Encoding_Latin3, StringToEncoding(EnumerationToString(Encoding_Latin3))); | |
808 ASSERT_EQ(Encoding_Latin4, StringToEncoding(EnumerationToString(Encoding_Latin4))); | |
809 ASSERT_EQ(Encoding_Latin5, StringToEncoding(EnumerationToString(Encoding_Latin5))); | |
810 ASSERT_EQ(Encoding_Cyrillic, StringToEncoding(EnumerationToString(Encoding_Cyrillic))); | |
811 ASSERT_EQ(Encoding_Arabic, StringToEncoding(EnumerationToString(Encoding_Arabic))); | |
812 ASSERT_EQ(Encoding_Greek, StringToEncoding(EnumerationToString(Encoding_Greek))); | |
813 ASSERT_EQ(Encoding_Hebrew, StringToEncoding(EnumerationToString(Encoding_Hebrew))); | |
814 ASSERT_EQ(Encoding_Japanese, StringToEncoding(EnumerationToString(Encoding_Japanese))); | |
815 ASSERT_EQ(Encoding_Chinese, StringToEncoding(EnumerationToString(Encoding_Chinese))); | |
816 ASSERT_EQ(Encoding_Thai, StringToEncoding(EnumerationToString(Encoding_Thai))); | |
817 ASSERT_EQ(Encoding_Korean, StringToEncoding(EnumerationToString(Encoding_Korean))); | |
818 ASSERT_EQ(Encoding_JapaneseKanji, StringToEncoding(EnumerationToString(Encoding_JapaneseKanji))); | |
819 ASSERT_EQ(Encoding_SimplifiedChinese, StringToEncoding(EnumerationToString(Encoding_SimplifiedChinese))); | |
820 | |
821 ASSERT_EQ(ResourceType_Patient, StringToResourceType(EnumerationToString(ResourceType_Patient))); | |
822 ASSERT_EQ(ResourceType_Study, StringToResourceType(EnumerationToString(ResourceType_Study))); | |
823 ASSERT_EQ(ResourceType_Series, StringToResourceType(EnumerationToString(ResourceType_Series))); | |
824 ASSERT_EQ(ResourceType_Instance, StringToResourceType(EnumerationToString(ResourceType_Instance))); | |
825 | |
826 ASSERT_EQ(ImageFormat_Png, StringToImageFormat(EnumerationToString(ImageFormat_Png))); | |
827 | |
828 ASSERT_EQ(PhotometricInterpretation_ARGB, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_ARGB))); | |
829 ASSERT_EQ(PhotometricInterpretation_CMYK, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_CMYK))); | |
830 ASSERT_EQ(PhotometricInterpretation_HSV, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_HSV))); | |
831 ASSERT_EQ(PhotometricInterpretation_Monochrome1, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_Monochrome1))); | |
832 ASSERT_EQ(PhotometricInterpretation_Monochrome2, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_Monochrome2))); | |
833 ASSERT_EQ(PhotometricInterpretation_Palette, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_Palette))); | |
834 ASSERT_EQ(PhotometricInterpretation_RGB, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_RGB))); | |
835 ASSERT_EQ(PhotometricInterpretation_YBRFull, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_YBRFull))); | |
836 ASSERT_EQ(PhotometricInterpretation_YBRFull422, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_YBRFull422))); | |
837 ASSERT_EQ(PhotometricInterpretation_YBRPartial420, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_YBRPartial420))); | |
838 ASSERT_EQ(PhotometricInterpretation_YBRPartial422, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_YBRPartial422))); | |
839 ASSERT_EQ(PhotometricInterpretation_YBR_ICT, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_YBR_ICT))); | |
840 ASSERT_EQ(PhotometricInterpretation_YBR_RCT, StringToPhotometricInterpretation(EnumerationToString(PhotometricInterpretation_YBR_RCT))); | |
841 | |
842 ASSERT_STREQ("Unknown", EnumerationToString(PhotometricInterpretation_Unknown)); | |
843 ASSERT_THROW(StringToPhotometricInterpretation("Unknown"), OrthancException); | |
844 | |
845 ASSERT_EQ(DicomVersion_2008, StringToDicomVersion(EnumerationToString(DicomVersion_2008))); | |
846 ASSERT_EQ(DicomVersion_2017c, StringToDicomVersion(EnumerationToString(DicomVersion_2017c))); | |
4677
521e39b3f2c0
Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4668
diff
changeset
|
847 ASSERT_EQ(DicomVersion_2021b, StringToDicomVersion(EnumerationToString(DicomVersion_2021b))); |
5334
5b2a5cc64cb1
upgraded anonymization to Basic Profile of PS 3.15-2023b Table E.1-1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5326
diff
changeset
|
848 ASSERT_EQ(DicomVersion_2023b, StringToDicomVersion(EnumerationToString(DicomVersion_2023b))); |
3987 | 849 |
850 for (int i = static_cast<int>(ValueRepresentation_ApplicationEntity); | |
851 i < static_cast<int>(ValueRepresentation_NotSupported); i += 1) | |
852 { | |
853 ValueRepresentation vr = static_cast<ValueRepresentation>(i); | |
854 ASSERT_EQ(vr, StringToValueRepresentation(EnumerationToString(vr), true)); | |
855 } | |
856 | |
857 ASSERT_THROW(StringToValueRepresentation("nope", true), OrthancException); | |
858 | |
859 ASSERT_EQ(JobState_Pending, StringToJobState(EnumerationToString(JobState_Pending))); | |
860 ASSERT_EQ(JobState_Running, StringToJobState(EnumerationToString(JobState_Running))); | |
861 ASSERT_EQ(JobState_Success, StringToJobState(EnumerationToString(JobState_Success))); | |
862 ASSERT_EQ(JobState_Failure, StringToJobState(EnumerationToString(JobState_Failure))); | |
863 ASSERT_EQ(JobState_Paused, StringToJobState(EnumerationToString(JobState_Paused))); | |
864 ASSERT_EQ(JobState_Retry, StringToJobState(EnumerationToString(JobState_Retry))); | |
865 ASSERT_THROW(StringToJobState("nope"), OrthancException); | |
866 | |
867 ASSERT_EQ(MimeType_Binary, StringToMimeType(EnumerationToString(MimeType_Binary))); | |
868 ASSERT_EQ(MimeType_Css, StringToMimeType(EnumerationToString(MimeType_Css))); | |
869 ASSERT_EQ(MimeType_Dicom, StringToMimeType(EnumerationToString(MimeType_Dicom))); | |
870 ASSERT_EQ(MimeType_Gif, StringToMimeType(EnumerationToString(MimeType_Gif))); | |
871 ASSERT_EQ(MimeType_Gzip, StringToMimeType(EnumerationToString(MimeType_Gzip))); | |
872 ASSERT_EQ(MimeType_Html, StringToMimeType(EnumerationToString(MimeType_Html))); | |
873 ASSERT_EQ(MimeType_JavaScript, StringToMimeType(EnumerationToString(MimeType_JavaScript))); | |
874 ASSERT_EQ(MimeType_Jpeg, StringToMimeType(EnumerationToString(MimeType_Jpeg))); | |
875 ASSERT_EQ(MimeType_Jpeg2000, StringToMimeType(EnumerationToString(MimeType_Jpeg2000))); | |
876 ASSERT_EQ(MimeType_Json, StringToMimeType(EnumerationToString(MimeType_Json))); | |
877 ASSERT_EQ(MimeType_NaCl, StringToMimeType(EnumerationToString(MimeType_NaCl))); | |
878 ASSERT_EQ(MimeType_PNaCl, StringToMimeType(EnumerationToString(MimeType_PNaCl))); | |
879 ASSERT_EQ(MimeType_Pam, StringToMimeType(EnumerationToString(MimeType_Pam))); | |
880 ASSERT_EQ(MimeType_Pdf, StringToMimeType(EnumerationToString(MimeType_Pdf))); | |
881 ASSERT_EQ(MimeType_PlainText, StringToMimeType(EnumerationToString(MimeType_PlainText))); | |
882 ASSERT_EQ(MimeType_Png, StringToMimeType(EnumerationToString(MimeType_Png))); | |
883 ASSERT_EQ(MimeType_Svg, StringToMimeType(EnumerationToString(MimeType_Svg))); | |
884 ASSERT_EQ(MimeType_WebAssembly, StringToMimeType(EnumerationToString(MimeType_WebAssembly))); | |
885 ASSERT_EQ(MimeType_Xml, StringToMimeType("application/xml")); | |
886 ASSERT_EQ(MimeType_Xml, StringToMimeType("text/xml")); | |
887 ASSERT_EQ(MimeType_Xml, StringToMimeType(EnumerationToString(MimeType_Xml))); | |
888 ASSERT_EQ(MimeType_DicomWebJson, StringToMimeType(EnumerationToString(MimeType_DicomWebJson))); | |
889 ASSERT_EQ(MimeType_DicomWebXml, StringToMimeType(EnumerationToString(MimeType_DicomWebXml))); | |
5348
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5337
diff
changeset
|
890 ASSERT_EQ(MimeType_Mtl, StringToMimeType(EnumerationToString(MimeType_Mtl))); |
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5337
diff
changeset
|
891 ASSERT_EQ(MimeType_Obj, StringToMimeType(EnumerationToString(MimeType_Obj))); |
303e930fff0f
"/tools/create-dicom" can now be used to create Encapsulated 3D Manufacturing Model IODs (MTL, OBJ, or STL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5337
diff
changeset
|
892 ASSERT_EQ(MimeType_Stl, StringToMimeType(EnumerationToString(MimeType_Stl))); |
3987 | 893 ASSERT_THROW(StringToMimeType("nope"), OrthancException); |
894 | |
895 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Patient, ResourceType_Patient)); | |
896 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Patient, ResourceType_Study)); | |
897 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Patient, ResourceType_Series)); | |
898 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Patient, ResourceType_Instance)); | |
899 | |
900 ASSERT_FALSE(IsResourceLevelAboveOrEqual(ResourceType_Study, ResourceType_Patient)); | |
901 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Study, ResourceType_Study)); | |
902 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Study, ResourceType_Series)); | |
903 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Study, ResourceType_Instance)); | |
904 | |
905 ASSERT_FALSE(IsResourceLevelAboveOrEqual(ResourceType_Series, ResourceType_Patient)); | |
906 ASSERT_FALSE(IsResourceLevelAboveOrEqual(ResourceType_Series, ResourceType_Study)); | |
907 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Series, ResourceType_Series)); | |
908 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Series, ResourceType_Instance)); | |
909 | |
910 ASSERT_FALSE(IsResourceLevelAboveOrEqual(ResourceType_Instance, ResourceType_Patient)); | |
911 ASSERT_FALSE(IsResourceLevelAboveOrEqual(ResourceType_Instance, ResourceType_Study)); | |
912 ASSERT_FALSE(IsResourceLevelAboveOrEqual(ResourceType_Instance, ResourceType_Series)); | |
913 ASSERT_TRUE(IsResourceLevelAboveOrEqual(ResourceType_Instance, ResourceType_Instance)); | |
4399
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
914 |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
915 ASSERT_STREQ("Patients", GetResourceTypeText(ResourceType_Patient, true /* plural */, true /* upper case */)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
916 ASSERT_STREQ("patients", GetResourceTypeText(ResourceType_Patient, true, false)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
917 ASSERT_STREQ("Patient", GetResourceTypeText(ResourceType_Patient, false, true)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
918 ASSERT_STREQ("patient", GetResourceTypeText(ResourceType_Patient, false, false)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
919 ASSERT_STREQ("Studies", GetResourceTypeText(ResourceType_Study, true, true)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
920 ASSERT_STREQ("studies", GetResourceTypeText(ResourceType_Study, true, false)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
921 ASSERT_STREQ("Study", GetResourceTypeText(ResourceType_Study, false, true)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
922 ASSERT_STREQ("study", GetResourceTypeText(ResourceType_Study, false, false)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
923 ASSERT_STREQ("Series", GetResourceTypeText(ResourceType_Series, true, true)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
924 ASSERT_STREQ("series", GetResourceTypeText(ResourceType_Series, true, false)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
925 ASSERT_STREQ("Series", GetResourceTypeText(ResourceType_Series, false, true)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
926 ASSERT_STREQ("series", GetResourceTypeText(ResourceType_Series, false, false)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
927 ASSERT_STREQ("Instances", GetResourceTypeText(ResourceType_Instance, true, true)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
928 ASSERT_STREQ("instances", GetResourceTypeText(ResourceType_Instance, true, false)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
929 ASSERT_STREQ("Instance", GetResourceTypeText(ResourceType_Instance, false, true)); |
80fd140b12ba
New command-line option: "--openapi" to write the OpenAPI documentation of the REST API to a file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4342
diff
changeset
|
930 ASSERT_STREQ("instance", GetResourceTypeText(ResourceType_Instance, false, false)); |
4668
9210e196cd98
unit test for transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4622
diff
changeset
|
931 |
9210e196cd98
unit test for transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4622
diff
changeset
|
932 DicomTransferSyntax ts; |
9210e196cd98
unit test for transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4622
diff
changeset
|
933 ASSERT_FALSE(LookupTransferSyntax(ts, "nope")); |
9210e196cd98
unit test for transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4622
diff
changeset
|
934 ASSERT_TRUE(LookupTransferSyntax(ts, "1.2.840.10008.1.2")); ASSERT_EQ(DicomTransferSyntax_LittleEndianImplicit, ts); |
9210e196cd98
unit test for transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4622
diff
changeset
|
935 ASSERT_STREQ("1.2.840.10008.1.2", GetTransferSyntaxUid(ts)); |
3987 | 936 } |
937 | |
938 | |
939 #if defined(__linux__) || defined(__OpenBSD__) | |
940 #include <endian.h> | |
941 #elif defined(__FreeBSD__) | |
942 #include <machine/endian.h> | |
943 #endif | |
944 | |
945 | |
946 TEST(Toolbox, Endianness) | |
947 { | |
948 // Parts of this test come from Adam Conrad | |
949 // http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728822#5 | |
950 | |
951 | |
952 /** | |
953 * Windows and OS X are assumed to always little-endian. | |
954 **/ | |
955 | |
956 #if defined(_WIN32) || defined(__APPLE__) | |
957 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); | |
958 | |
959 | |
960 /** | |
961 * FreeBSD. | |
962 **/ | |
963 | |
964 #elif defined(__FreeBSD__) || defined(__OpenBSD__) | |
965 # if _BYTE_ORDER == _BIG_ENDIAN | |
966 ASSERT_EQ(Endianness_Big, Toolbox::DetectEndianness()); | |
967 # else // _LITTLE_ENDIAN | |
968 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); | |
969 # endif | |
970 | |
971 | |
972 /** | |
973 * Linux. | |
974 **/ | |
975 | |
976 #elif defined(__linux__) || defined(__FreeBSD_kernel__) | |
977 | |
978 #if !defined(__BYTE_ORDER) | |
979 # error Support your platform here | |
980 #endif | |
981 | |
982 # if __BYTE_ORDER == __BIG_ENDIAN | |
983 ASSERT_EQ(Endianness_Big, Toolbox::DetectEndianness()); | |
984 # else // __LITTLE_ENDIAN | |
985 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); | |
986 # endif | |
987 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
988 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
989 /** |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
990 * WebAssembly is always little-endian. |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
991 **/ |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
992 |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
993 #elif defined(__EMSCRIPTEN__) |
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
994 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); |
3987 | 995 #else |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
996 # error Support your platform here |
3987 | 997 #endif |
998 } | |
999 | |
1000 | |
4045 | 1001 #include "../Sources/Endianness.h" |
3987 | 1002 |
1003 static void ASSERT_EQ16(uint16_t a, uint16_t b) | |
1004 { | |
1005 #ifdef __MINGW32__ | |
1006 // This cast solves a linking problem with MinGW | |
1007 ASSERT_EQ(static_cast<unsigned int>(a), static_cast<unsigned int>(b)); | |
1008 #else | |
1009 ASSERT_EQ(a, b); | |
1010 #endif | |
1011 } | |
1012 | |
1013 static void ASSERT_NE16(uint16_t a, uint16_t b) | |
1014 { | |
1015 #ifdef __MINGW32__ | |
1016 // This cast solves a linking problem with MinGW | |
1017 ASSERT_NE(static_cast<unsigned int>(a), static_cast<unsigned int>(b)); | |
1018 #else | |
1019 ASSERT_NE(a, b); | |
1020 #endif | |
1021 } | |
1022 | |
1023 static void ASSERT_EQ32(uint32_t a, uint32_t b) | |
1024 { | |
1025 #ifdef __MINGW32__ | |
1026 // This cast solves a linking problem with MinGW | |
1027 ASSERT_EQ(static_cast<unsigned int>(a), static_cast<unsigned int>(b)); | |
1028 #else | |
1029 ASSERT_EQ(a, b); | |
1030 #endif | |
1031 } | |
1032 | |
1033 static void ASSERT_NE32(uint32_t a, uint32_t b) | |
1034 { | |
1035 #ifdef __MINGW32__ | |
1036 // This cast solves a linking problem with MinGW | |
1037 ASSERT_NE(static_cast<unsigned int>(a), static_cast<unsigned int>(b)); | |
1038 #else | |
1039 ASSERT_NE(a, b); | |
1040 #endif | |
1041 } | |
1042 | |
1043 static void ASSERT_EQ64(uint64_t a, uint64_t b) | |
1044 { | |
1045 #ifdef __MINGW32__ | |
1046 // This cast solves a linking problem with MinGW | |
1047 ASSERT_EQ(static_cast<unsigned int>(a), static_cast<unsigned int>(b)); | |
1048 #else | |
1049 ASSERT_EQ(a, b); | |
1050 #endif | |
1051 } | |
1052 | |
1053 static void ASSERT_NE64(uint64_t a, uint64_t b) | |
1054 { | |
1055 #ifdef __MINGW32__ | |
1056 // This cast solves a linking problem with MinGW | |
1057 ASSERT_NE(static_cast<unsigned long long>(a), static_cast<unsigned long long>(b)); | |
1058 #else | |
1059 ASSERT_NE(a, b); | |
1060 #endif | |
1061 } | |
1062 | |
1063 | |
1064 | |
1065 TEST(Toolbox, EndiannessConversions16) | |
1066 { | |
1067 Endianness e = Toolbox::DetectEndianness(); | |
1068 | |
1069 for (unsigned int i = 0; i < 65536; i += 17) | |
1070 { | |
1071 uint16_t v = static_cast<uint16_t>(i); | |
1072 ASSERT_EQ16(v, be16toh(htobe16(v))); | |
1073 ASSERT_EQ16(v, le16toh(htole16(v))); | |
1074 | |
1075 const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&v); | |
1076 if (bytes[0] != bytes[1]) | |
1077 { | |
1078 ASSERT_NE16(v, le16toh(htobe16(v))); | |
1079 ASSERT_NE16(v, be16toh(htole16(v))); | |
1080 } | |
1081 else | |
1082 { | |
1083 ASSERT_EQ16(v, le16toh(htobe16(v))); | |
1084 ASSERT_EQ16(v, be16toh(htole16(v))); | |
1085 } | |
1086 | |
1087 switch (e) | |
1088 { | |
1089 case Endianness_Little: | |
1090 ASSERT_EQ16(v, htole16(v)); | |
1091 if (bytes[0] != bytes[1]) | |
1092 { | |
1093 ASSERT_NE16(v, htobe16(v)); | |
1094 } | |
1095 else | |
1096 { | |
1097 ASSERT_EQ16(v, htobe16(v)); | |
1098 } | |
1099 break; | |
1100 | |
1101 case Endianness_Big: | |
1102 ASSERT_EQ16(v, htobe16(v)); | |
1103 if (bytes[0] != bytes[1]) | |
1104 { | |
1105 ASSERT_NE16(v, htole16(v)); | |
1106 } | |
1107 else | |
1108 { | |
1109 ASSERT_EQ16(v, htole16(v)); | |
1110 } | |
1111 break; | |
1112 | |
1113 default: | |
1114 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1115 } | |
1116 } | |
1117 } | |
1118 | |
1119 | |
1120 TEST(Toolbox, EndiannessConversions32) | |
1121 { | |
1122 const uint32_t v = 0xff010203u; | |
1123 const uint32_t r = 0x030201ffu; | |
1124 ASSERT_EQ32(v, be32toh(htobe32(v))); | |
1125 ASSERT_EQ32(v, le32toh(htole32(v))); | |
1126 ASSERT_NE32(v, be32toh(htole32(v))); | |
1127 ASSERT_NE32(v, le32toh(htobe32(v))); | |
1128 | |
1129 switch (Toolbox::DetectEndianness()) | |
1130 { | |
1131 case Endianness_Little: | |
1132 ASSERT_EQ32(r, htobe32(v)); | |
1133 ASSERT_EQ32(v, htole32(v)); | |
1134 ASSERT_EQ32(r, be32toh(v)); | |
1135 ASSERT_EQ32(v, le32toh(v)); | |
1136 break; | |
1137 | |
1138 case Endianness_Big: | |
1139 ASSERT_EQ32(v, htobe32(v)); | |
1140 ASSERT_EQ32(r, htole32(v)); | |
1141 ASSERT_EQ32(v, be32toh(v)); | |
1142 ASSERT_EQ32(r, le32toh(v)); | |
1143 break; | |
1144 | |
1145 default: | |
1146 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1147 } | |
1148 } | |
1149 | |
1150 | |
1151 TEST(Toolbox, EndiannessConversions64) | |
1152 { | |
1153 const uint64_t v = 0xff01020304050607LL; | |
1154 const uint64_t r = 0x07060504030201ffLL; | |
1155 ASSERT_EQ64(v, be64toh(htobe64(v))); | |
1156 ASSERT_EQ64(v, le64toh(htole64(v))); | |
1157 ASSERT_NE64(v, be64toh(htole64(v))); | |
1158 ASSERT_NE64(v, le64toh(htobe64(v))); | |
1159 | |
1160 switch (Toolbox::DetectEndianness()) | |
1161 { | |
1162 case Endianness_Little: | |
1163 ASSERT_EQ64(r, htobe64(v)); | |
1164 ASSERT_EQ64(v, htole64(v)); | |
1165 ASSERT_EQ64(r, be64toh(v)); | |
1166 ASSERT_EQ64(v, le64toh(v)); | |
1167 break; | |
1168 | |
1169 case Endianness_Big: | |
1170 ASSERT_EQ64(v, htobe64(v)); | |
1171 ASSERT_EQ64(r, htole64(v)); | |
1172 ASSERT_EQ64(v, be64toh(v)); | |
1173 ASSERT_EQ64(r, le64toh(v)); | |
1174 break; | |
1175 | |
1176 default: | |
1177 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1178 } | |
1179 } | |
1180 | |
1181 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
1182 #if ORTHANC_SANDBOXED != 1 |
3987 | 1183 TEST(Toolbox, Now) |
1184 { | |
1185 LOG(WARNING) << "Local time: " << SystemToolbox::GetNowIsoString(false); | |
1186 LOG(WARNING) << "Universal time: " << SystemToolbox::GetNowIsoString(true); | |
1187 | |
1188 std::string date, time; | |
1189 SystemToolbox::GetNowDicom(date, time, false); | |
1190 LOG(WARNING) << "Local DICOM time: [" << date << "] [" << time << "]"; | |
1191 | |
1192 SystemToolbox::GetNowDicom(date, time, true); | |
1193 LOG(WARNING) << "Universal DICOM time: [" << date << "] [" << time << "]"; | |
1194 } | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
1195 #endif |
3987 | 1196 |
1197 | |
1198 #if ORTHANC_ENABLE_PUGIXML == 1 | |
1199 TEST(Toolbox, Xml) | |
1200 { | |
1201 Json::Value a; | |
1202 a["hello"] = "world"; | |
1203 a["42"] = 43; | |
1204 a["b"] = Json::arrayValue; | |
1205 a["b"].append("test"); | |
1206 a["b"].append("test2"); | |
1207 | |
1208 std::string s; | |
1209 Toolbox::JsonToXml(s, a); | |
1210 | |
1211 std::cout << s; | |
1212 } | |
1213 #endif | |
1214 | |
1215 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
1216 #if !defined(_WIN32) && (ORTHANC_SANDBOXED != 1) |
3987 | 1217 TEST(Toolbox, ExecuteSystemCommand) |
1218 { | |
1219 std::vector<std::string> args(2); | |
1220 args[0] = "Hello"; | |
1221 args[1] = "World"; | |
1222 | |
1223 SystemToolbox::ExecuteSystemCommand("echo", args); | |
1224 } | |
1225 #endif | |
1226 | |
1227 | |
1228 TEST(Toolbox, IsInteger) | |
1229 { | |
1230 ASSERT_TRUE(Toolbox::IsInteger("00236")); | |
1231 ASSERT_TRUE(Toolbox::IsInteger("-0042")); | |
1232 ASSERT_TRUE(Toolbox::IsInteger("0")); | |
1233 ASSERT_TRUE(Toolbox::IsInteger("-0")); | |
1234 | |
1235 ASSERT_FALSE(Toolbox::IsInteger("")); | |
1236 ASSERT_FALSE(Toolbox::IsInteger("42a")); | |
1237 ASSERT_FALSE(Toolbox::IsInteger("42-")); | |
1238 } | |
1239 | |
1240 | |
1241 TEST(Toolbox, StartsWith) | |
1242 { | |
1243 ASSERT_TRUE(Toolbox::StartsWith("hello world", "")); | |
1244 ASSERT_TRUE(Toolbox::StartsWith("hello world", "hello")); | |
1245 ASSERT_TRUE(Toolbox::StartsWith("hello world", "h")); | |
1246 ASSERT_FALSE(Toolbox::StartsWith("hello world", "H")); | |
1247 ASSERT_FALSE(Toolbox::StartsWith("h", "hello")); | |
1248 ASSERT_TRUE(Toolbox::StartsWith("h", "h")); | |
1249 ASSERT_FALSE(Toolbox::StartsWith("", "h")); | |
1250 } | |
1251 | |
1252 | |
1253 TEST(Toolbox, UriEncode) | |
1254 { | |
1255 std::string s; | |
1256 | |
1257 // Unreserved characters must not be modified | |
1258 std::string t = "aAzZ09.-~_"; | |
1259 Toolbox::UriEncode(s, t); | |
1260 ASSERT_EQ(t, s); | |
1261 | |
4234
a38376b80cd1
WebDAV: by-studies and by-patients
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4186
diff
changeset
|
1262 Toolbox::UriEncode(s, "!#$&'()*+,/:;=?@[]"); ASSERT_EQ("%21%23%24%26%27%28%29%2A%2B%2C/%3A%3B%3D%3F%40%5B%5D", s); |
3987 | 1263 Toolbox::UriEncode(s, "%"); ASSERT_EQ("%25", s); |
1264 | |
1265 // Encode characters from UTF-8. This is the test string from the | |
1266 // file "../Resources/EncodingTests.py" | |
1267 Toolbox::UriEncode(s, "\x54\x65\x73\x74\xc3\xa9\xc3\xa4\xc3\xb6\xc3\xb2\xd0\x94\xce\x98\xc4\x9d\xd7\x93\xd8\xb5\xc4\xb7\xd1\x9b\xe0\xb9\x9b\xef\xbe\x88\xc4\xb0"); | |
1268 ASSERT_EQ("Test%C3%A9%C3%A4%C3%B6%C3%B2%D0%94%CE%98%C4%9D%D7%93%D8%B5%C4%B7%D1%9B%E0%B9%9B%EF%BE%88%C4%B0", s); | |
1269 } | |
1270 | |
1271 | |
1272 TEST(Toolbox, AccessJson) | |
1273 { | |
1274 Json::Value v = Json::arrayValue; | |
1275 ASSERT_EQ("nope", Toolbox::GetJsonStringField(v, "hello", "nope")); | |
1276 | |
1277 v = Json::objectValue; | |
1278 ASSERT_EQ("nope", Toolbox::GetJsonStringField(v, "hello", "nope")); | |
1279 ASSERT_EQ(-10, Toolbox::GetJsonIntegerField(v, "hello", -10)); | |
1280 ASSERT_EQ(10u, Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10)); | |
1281 ASSERT_TRUE(Toolbox::GetJsonBooleanField(v, "hello", true)); | |
1282 | |
1283 v["hello"] = "world"; | |
1284 ASSERT_EQ("world", Toolbox::GetJsonStringField(v, "hello", "nope")); | |
1285 ASSERT_THROW(Toolbox::GetJsonIntegerField(v, "hello", -10), OrthancException); | |
1286 ASSERT_THROW(Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10), OrthancException); | |
1287 ASSERT_THROW(Toolbox::GetJsonBooleanField(v, "hello", true), OrthancException); | |
1288 | |
1289 v["hello"] = -42; | |
1290 ASSERT_THROW(Toolbox::GetJsonStringField(v, "hello", "nope"), OrthancException); | |
1291 ASSERT_EQ(-42, Toolbox::GetJsonIntegerField(v, "hello", -10)); | |
1292 ASSERT_THROW(Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10), OrthancException); | |
1293 ASSERT_THROW(Toolbox::GetJsonBooleanField(v, "hello", true), OrthancException); | |
1294 | |
1295 v["hello"] = 42; | |
1296 ASSERT_THROW(Toolbox::GetJsonStringField(v, "hello", "nope"), OrthancException); | |
1297 ASSERT_EQ(42, Toolbox::GetJsonIntegerField(v, "hello", -10)); | |
1298 ASSERT_EQ(42u, Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10)); | |
1299 ASSERT_THROW(Toolbox::GetJsonBooleanField(v, "hello", true), OrthancException); | |
1300 | |
1301 v["hello"] = false; | |
1302 ASSERT_THROW(Toolbox::GetJsonStringField(v, "hello", "nope"), OrthancException); | |
1303 ASSERT_THROW(Toolbox::GetJsonIntegerField(v, "hello", -10), OrthancException); | |
1304 ASSERT_THROW(Toolbox::GetJsonUnsignedIntegerField(v, "hello", 10), OrthancException); | |
1305 ASSERT_FALSE(Toolbox::GetJsonBooleanField(v, "hello", true)); | |
1306 } | |
1307 | |
1308 | |
1309 TEST(Toolbox, LinesIterator) | |
1310 { | |
1311 std::string s; | |
1312 | |
1313 { | |
1314 std::string content; | |
1315 Toolbox::LinesIterator it(content); | |
1316 ASSERT_FALSE(it.GetLine(s)); | |
1317 } | |
1318 | |
1319 { | |
1320 std::string content = "\n\r"; | |
1321 Toolbox::LinesIterator it(content); | |
1322 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1323 ASSERT_FALSE(it.GetLine(s)); | |
1324 } | |
1325 | |
1326 { | |
1327 std::string content = "\n Hello \n\nWorld\n\n"; | |
1328 Toolbox::LinesIterator it(content); | |
1329 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1330 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ(" Hello ", s); | |
1331 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1332 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("World", s); | |
1333 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1334 ASSERT_FALSE(it.GetLine(s)); it.Next(); | |
1335 ASSERT_FALSE(it.GetLine(s)); | |
1336 } | |
1337 | |
1338 { | |
1339 std::string content = "\r Hello \r\rWorld\r\r"; | |
1340 Toolbox::LinesIterator it(content); | |
1341 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1342 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ(" Hello ", s); | |
1343 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1344 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("World", s); | |
1345 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1346 ASSERT_FALSE(it.GetLine(s)); it.Next(); | |
1347 ASSERT_FALSE(it.GetLine(s)); | |
1348 } | |
1349 | |
1350 { | |
1351 std::string content = "\n\r Hello \n\r\n\rWorld\n\r\n\r"; | |
1352 Toolbox::LinesIterator it(content); | |
1353 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1354 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ(" Hello ", s); | |
1355 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1356 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("World", s); | |
1357 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1358 ASSERT_FALSE(it.GetLine(s)); it.Next(); | |
1359 ASSERT_FALSE(it.GetLine(s)); | |
1360 } | |
1361 | |
1362 { | |
1363 std::string content = "\r\n Hello \r\n\r\nWorld\r\n\r\n"; | |
1364 Toolbox::LinesIterator it(content); | |
1365 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1366 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ(" Hello ", s); | |
1367 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1368 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("World", s); | |
1369 ASSERT_TRUE(it.GetLine(s)); it.Next(); ASSERT_EQ("", s); | |
1370 ASSERT_FALSE(it.GetLine(s)); it.Next(); | |
1371 ASSERT_FALSE(it.GetLine(s)); | |
1372 } | |
1373 } | |
1374 | |
1375 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
1376 #if ORTHANC_SANDBOXED != 1 |
3987 | 1377 TEST(Toolbox, SubstituteVariables) |
1378 { | |
1379 std::map<std::string, std::string> env; | |
1380 env["NOPE"] = "nope"; | |
1381 env["WORLD"] = "world"; | |
1382 | |
1383 ASSERT_EQ("Hello world\r\nWorld \r\nDone world\r\n", | |
1384 Toolbox::SubstituteVariables( | |
1385 "Hello ${WORLD}\r\nWorld ${HELLO}\r\nDone ${WORLD}\r\n", | |
1386 env)); | |
1387 | |
1388 ASSERT_EQ("world A a B world C 'c' D {\"a\":\"b\"} E ", | |
1389 Toolbox::SubstituteVariables( | |
1390 "${WORLD} A ${WORLD2:-a} B ${WORLD:-b} C ${WORLD2:-\"'c'\"} D ${WORLD2:-'{\"a\":\"b\"}'} E ${WORLD2:-}", | |
1391 env)); | |
1392 | |
1393 SystemToolbox::GetEnvironmentVariables(env); | |
1394 ASSERT_TRUE(env.find("NOPE") == env.end()); | |
1395 | |
1396 // The "PATH" environment variable should always be available on | |
1397 // machines running the unit tests | |
1398 ASSERT_TRUE(env.find("PATH") != env.end() /* Case used by UNIX */ || | |
1399 env.find("Path") != env.end() /* Case used by Windows */); | |
1400 | |
1401 env["PATH"] = "hello"; | |
1402 ASSERT_EQ("AhelloB", | |
1403 Toolbox::SubstituteVariables("A${PATH}B", env)); | |
1404 } | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
1405 #endif |
3987 | 1406 |
1407 | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
1408 #if ORTHANC_SANDBOXED != 1 |
3987 | 1409 TEST(MetricsRegistry, Basic) |
1410 { | |
1411 { | |
1412 MetricsRegistry m; | |
1413 m.SetEnabled(false); | |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1414 m.SetIntegerValue("hello.world", 42); |
3987 | 1415 |
1416 std::string s; | |
1417 m.ExportPrometheusText(s); | |
1418 ASSERT_TRUE(s.empty()); | |
1419 } | |
1420 | |
1421 { | |
1422 MetricsRegistry m; | |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1423 m.Register("hello.world", MetricsUpdatePolicy_Directly, MetricsDataType_Integer); |
3987 | 1424 |
1425 std::string s; | |
1426 m.ExportPrometheusText(s); | |
1427 ASSERT_TRUE(s.empty()); | |
1428 } | |
1429 | |
1430 { | |
1431 MetricsRegistry m; | |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1432 m.SetIntegerValue("hello.world", -42); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1433 ASSERT_EQ(MetricsUpdatePolicy_Directly, m.GetUpdatePolicy("hello.world")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1434 ASSERT_THROW(m.GetUpdatePolicy("nope"), OrthancException); |
3987 | 1435 |
1436 std::string s; | |
1437 m.ExportPrometheusText(s); | |
1438 | |
1439 std::vector<std::string> t; | |
1440 Toolbox::TokenizeString(t, s, '\n'); | |
1441 ASSERT_EQ(2u, t.size()); | |
5326
fbe857e942cd
store metrics as integers instead of floats to avoid precision loss in increments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
1442 ASSERT_EQ("hello.world -42 ", t[0].substr(0, 16)); |
3987 | 1443 ASSERT_TRUE(t[1].empty()); |
1444 } | |
1445 | |
1446 { | |
1447 MetricsRegistry m; | |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1448 m.Register("hello.max", MetricsUpdatePolicy_MaxOver10Seconds, MetricsDataType_Integer); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1449 m.SetIntegerValue("hello.max", 10); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1450 m.SetIntegerValue("hello.max", 20); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1451 m.SetIntegerValue("hello.max", -10); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1452 m.SetIntegerValue("hello.max", 5); |
3987 | 1453 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1454 m.Register("hello.min", MetricsUpdatePolicy_MinOver10Seconds, MetricsDataType_Integer); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1455 m.SetIntegerValue("hello.min", 10); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1456 m.SetIntegerValue("hello.min", 20); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1457 m.SetIntegerValue("hello.min", -10); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1458 m.SetIntegerValue("hello.min", 5); |
3987 | 1459 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1460 m.Register("hello.directly", MetricsUpdatePolicy_Directly, MetricsDataType_Integer); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1461 m.SetIntegerValue("hello.directly", 10); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1462 m.SetIntegerValue("hello.directly", 20); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1463 m.SetIntegerValue("hello.directly", -10); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1464 m.SetIntegerValue("hello.directly", 5); |
3987 | 1465 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1466 ASSERT_EQ(MetricsUpdatePolicy_MaxOver10Seconds, m.GetUpdatePolicy("hello.max")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1467 ASSERT_EQ(MetricsUpdatePolicy_MinOver10Seconds, m.GetUpdatePolicy("hello.min")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1468 ASSERT_EQ(MetricsUpdatePolicy_Directly, m.GetUpdatePolicy("hello.directly")); |
3987 | 1469 |
1470 std::string s; | |
1471 m.ExportPrometheusText(s); | |
1472 | |
1473 std::vector<std::string> t; | |
1474 Toolbox::TokenizeString(t, s, '\n'); | |
1475 ASSERT_EQ(4u, t.size()); | |
1476 ASSERT_TRUE(t[3].empty()); | |
1477 | |
1478 std::map<std::string, std::string> u; | |
1479 for (size_t i = 0; i < t.size() - 1; i++) | |
1480 { | |
1481 std::vector<std::string> v; | |
1482 Toolbox::TokenizeString(v, t[i], ' '); | |
1483 u[v[0]] = v[1]; | |
1484 } | |
1485 | |
1486 ASSERT_EQ("20", u["hello.max"]); | |
1487 ASSERT_EQ("-10", u["hello.min"]); | |
5336
dd9795dc380d
renamed MetricsType as MetricsUpdate to clarify
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5334
diff
changeset
|
1488 ASSERT_EQ("5", u["hello.directly"]); |
3987 | 1489 } |
1490 | |
1491 { | |
1492 MetricsRegistry m; | |
1493 | |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1494 m.SetIntegerValue("a", 10); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1495 m.SetIntegerValue("b", 10, MetricsUpdatePolicy_MinOver10Seconds); |
3987 | 1496 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1497 m.Register("c", MetricsUpdatePolicy_MaxOver10Seconds, MetricsDataType_Integer); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1498 m.SetIntegerValue("c", 10, MetricsUpdatePolicy_MinOver10Seconds); |
3987 | 1499 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1500 m.Register("d", MetricsUpdatePolicy_MaxOver10Seconds, MetricsDataType_Integer); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1501 ASSERT_THROW(m.Register("d", MetricsUpdatePolicy_Directly, MetricsDataType_Integer), OrthancException); |
3987 | 1502 |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1503 ASSERT_EQ(MetricsUpdatePolicy_Directly, m.GetUpdatePolicy("a")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1504 ASSERT_EQ(MetricsUpdatePolicy_MinOver10Seconds, m.GetUpdatePolicy("b")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1505 ASSERT_EQ(MetricsUpdatePolicy_MaxOver10Seconds, m.GetUpdatePolicy("c")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1506 ASSERT_EQ(MetricsUpdatePolicy_MaxOver10Seconds, m.GetUpdatePolicy("d")); |
3987 | 1507 } |
1508 | |
1509 { | |
1510 MetricsRegistry m; | |
1511 | |
1512 { | |
1513 MetricsRegistry::Timer t1(m, "a"); | |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1514 MetricsRegistry::Timer t2(m, "b", MetricsUpdatePolicy_MinOver10Seconds); |
3987 | 1515 } |
1516 | |
5337
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1517 ASSERT_EQ(MetricsUpdatePolicy_MaxOver10Seconds, m.GetUpdatePolicy("a")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1518 ASSERT_EQ(MetricsUpdatePolicy_MinOver10Seconds, m.GetUpdatePolicy("b")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1519 } |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1520 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1521 { |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1522 MetricsRegistry m; |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1523 m.Register("c", MetricsUpdatePolicy_MaxOver10Seconds, MetricsDataType_Integer); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1524 m.SetFloatValue("c", 100, MetricsUpdatePolicy_MinOver10Seconds); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1525 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1526 ASSERT_EQ(MetricsUpdatePolicy_MaxOver10Seconds, m.GetUpdatePolicy("c")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1527 ASSERT_EQ(MetricsDataType_Integer, m.GetDataType("c")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1528 } |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1529 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1530 { |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1531 MetricsRegistry m; |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1532 m.Register("c", MetricsUpdatePolicy_MaxOver10Seconds, MetricsDataType_Float); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1533 m.SetIntegerValue("c", 100, MetricsUpdatePolicy_MinOver10Seconds); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1534 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1535 ASSERT_EQ(MetricsUpdatePolicy_MaxOver10Seconds, m.GetUpdatePolicy("c")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1536 ASSERT_EQ(MetricsDataType_Float, m.GetDataType("c")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1537 } |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1538 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1539 { |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1540 MetricsRegistry m; |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1541 m.SetIntegerValue("c", 100, MetricsUpdatePolicy_MinOver10Seconds); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1542 m.SetFloatValue("c", 101, MetricsUpdatePolicy_MaxOver10Seconds); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1543 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1544 ASSERT_EQ(MetricsUpdatePolicy_MinOver10Seconds, m.GetUpdatePolicy("c")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1545 ASSERT_EQ(MetricsDataType_Integer, m.GetDataType("c")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1546 } |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1547 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1548 { |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1549 MetricsRegistry m; |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1550 m.SetIntegerValue("c", 100); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1551 m.SetFloatValue("c", 101, MetricsUpdatePolicy_MaxOver10Seconds); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1552 |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1553 ASSERT_EQ(MetricsUpdatePolicy_Directly, m.GetUpdatePolicy("c")); |
b376abae664a
Metrics can be stored either as floating-point numbers, or as integers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5336
diff
changeset
|
1554 ASSERT_EQ(MetricsDataType_Integer, m.GetDataType("c")); |
3987 | 1555 } |
1556 } | |
4325
b96aedfa8cc1
unit tests now running in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4234
diff
changeset
|
1557 #endif |
4342
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1558 |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1559 |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1560 #if ORTHANC_SANDBOXED != 1 |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1561 TEST(Toolbox, ReadFileRange) |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1562 { |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1563 TemporaryFile tmp; |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1564 std::string s; |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1565 |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1566 tmp.Write(""); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1567 tmp.Read(s); ASSERT_TRUE(s.empty()); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1568 tmp.ReadRange(s, 0, 0, true); ASSERT_TRUE(s.empty()); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1569 tmp.ReadRange(s, 0, 10, false); ASSERT_TRUE(s.empty()); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1570 |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1571 ASSERT_THROW(tmp.ReadRange(s, 0, 1, true), OrthancException); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1572 |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1573 tmp.Write("Hello"); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1574 tmp.Read(s); ASSERT_EQ("Hello", s); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1575 tmp.ReadRange(s, 0, 5, true); ASSERT_EQ("Hello", s); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1576 tmp.ReadRange(s, 0, 1, true); ASSERT_EQ("H", s); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1577 tmp.ReadRange(s, 1, 2, true); ASSERT_EQ("e", s); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1578 tmp.ReadRange(s, 2, 3, true); ASSERT_EQ("l", s); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1579 tmp.ReadRange(s, 3, 4, true); ASSERT_EQ("l", s); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1580 tmp.ReadRange(s, 4, 5, true); ASSERT_EQ("o", s); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1581 tmp.ReadRange(s, 2, 5, true); ASSERT_EQ("llo", s); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1582 tmp.ReadRange(s, 2, 50, false); ASSERT_EQ("llo", s); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1583 tmp.ReadRange(s, 2, 2, false); ASSERT_TRUE(s.empty()); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1584 tmp.ReadRange(s, 10, 50, false); ASSERT_TRUE(s.empty()); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1585 |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1586 ASSERT_THROW(tmp.ReadRange(s, 5, 10, true), OrthancException); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1587 ASSERT_THROW(tmp.ReadRange(s, 10, 50, true), OrthancException); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1588 ASSERT_THROW(tmp.ReadRange(s, 50, 10, true), OrthancException); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1589 ASSERT_THROW(tmp.ReadRange(s, 2, 1, true), OrthancException); |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1590 } |
52166629239f
SystemToolbox::ReadFileRange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4330
diff
changeset
|
1591 #endif |
4538
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1592 |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1593 |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1594 #if ORTHANC_SANDBOXED != 1 |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1595 TEST(Toolbox, GetMacAddressess) |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1596 { |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1597 std::set<std::string> mac; |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1598 SystemToolbox::GetMacAddresses(mac); |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1599 |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1600 for (std::set<std::string>::const_iterator it = mac.begin(); it != mac.end(); ++it) |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1601 { |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1602 printf("MAC address: [%s]\n", it->c_str()); |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1603 } |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1604 } |
8a7523da6a9b
added SystemToolbox::GetMacAddresses()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
1605 #endif |
5575
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1606 |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1607 |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1608 TEST(Toolbox, IsVersionAbove) |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1609 { |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1610 unsigned int a, b, c; |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1611 ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "nope")); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1612 ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "mainline")); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1613 ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "")); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1614 ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "-1")); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1615 ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "1.-1")); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1616 ASSERT_FALSE(Toolbox::ParseVersion(a, b, c, "1.1.-1")); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1617 |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1618 ASSERT_TRUE(Toolbox::ParseVersion(a, b, c, "14.17.20")); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1619 ASSERT_EQ(14u, a); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1620 ASSERT_EQ(17u, b); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1621 ASSERT_EQ(20u, c); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1622 |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1623 ASSERT_TRUE(Toolbox::ParseVersion(a, b, c, "18.19")); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1624 ASSERT_EQ(18u, a); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1625 ASSERT_EQ(19u, b); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1626 ASSERT_EQ(0u, c); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1627 |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1628 ASSERT_TRUE(Toolbox::ParseVersion(a, b, c, "78")); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1629 ASSERT_EQ(78u, a); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1630 ASSERT_EQ(0u, b); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1631 ASSERT_EQ(0u, c); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1632 |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1633 ASSERT_TRUE(Toolbox::IsVersionAbove("mainline", 99, 99, 99)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1634 |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1635 ASSERT_TRUE(Toolbox::IsVersionAbove("18", 17, 99, 99)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1636 ASSERT_TRUE(Toolbox::IsVersionAbove("18", 18, 0, 0)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1637 ASSERT_FALSE(Toolbox::IsVersionAbove("18", 18, 0, 1)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1638 ASSERT_FALSE(Toolbox::IsVersionAbove("18", 18, 1, 0)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1639 ASSERT_FALSE(Toolbox::IsVersionAbove("18", 19, 0, 0)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1640 |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1641 ASSERT_TRUE(Toolbox::IsVersionAbove("18.19", 17, 99, 99)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1642 ASSERT_TRUE(Toolbox::IsVersionAbove("18.19", 18, 18, 99)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1643 ASSERT_TRUE(Toolbox::IsVersionAbove("18.19", 18, 19, 0)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1644 ASSERT_FALSE(Toolbox::IsVersionAbove("18.19", 18, 19, 1)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1645 ASSERT_FALSE(Toolbox::IsVersionAbove("18.19", 18, 20, 0)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1646 ASSERT_FALSE(Toolbox::IsVersionAbove("18.19", 19, 0, 0)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1647 |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1648 ASSERT_TRUE(Toolbox::IsVersionAbove("18.19.20", 17, 99, 99)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1649 ASSERT_TRUE(Toolbox::IsVersionAbove("18.19.20", 18, 18, 99)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1650 ASSERT_TRUE(Toolbox::IsVersionAbove("18.19.20", 18, 19, 19)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1651 ASSERT_TRUE(Toolbox::IsVersionAbove("18.19.20", 18, 19, 20)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1652 ASSERT_FALSE(Toolbox::IsVersionAbove("18.19.20", 18, 19, 21)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1653 ASSERT_FALSE(Toolbox::IsVersionAbove("18.19.20", 18, 20, 0)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1654 ASSERT_FALSE(Toolbox::IsVersionAbove("18.19.20", 19, 0, 0)); |
d7eaa568da15
Orthanc::Logging automatically detects whether the Orthanc core supports OrthancPluginLogMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
1655 } |