Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/ToolboxTests.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 |
---|---|
3373
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
1 /** |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
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:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5430
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
3373
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
8 * |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
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. |
3373
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
13 * |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
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. |
3373
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
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/>. |
3373
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
22 **/ |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
23 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
24 |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
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:
3713
diff
changeset
|
28 #endif |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
29 |
4062 | 30 #include <gtest/gtest.h> |
31 | |
4045 | 32 #include "../Sources/Compatibility.h" |
33 #include "../Sources/IDynamicObject.h" | |
34 #include "../Sources/OrthancException.h" | |
35 #include "../Sources/Toolbox.h" | |
3373
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
36 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
37 using namespace Orthanc; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
38 |
4393
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
39 TEST(Toolbox, Json) |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
40 { |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
41 Json::Value a = Json::objectValue; |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
42 a["hello"] = "world"; |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
43 |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
44 std::string b = "{\"hello\" : \"world\"}"; |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
45 |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
46 Json::Value c; |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
47 ASSERT_TRUE(Toolbox::ReadJson(c, b)); |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
48 |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
49 std::string d, e; |
4394
f7104e9d044c
functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4393
diff
changeset
|
50 Toolbox::WriteFastJson(d, a); |
f7104e9d044c
functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4393
diff
changeset
|
51 Toolbox::WriteFastJson(e, c); |
4393
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
52 ASSERT_EQ(d, e); |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
53 |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
54 std::string f, g; |
4394
f7104e9d044c
functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4393
diff
changeset
|
55 Toolbox::WriteStyledJson(f, a); |
f7104e9d044c
functions to read/write JSON in OrthancPluginCppWrapper.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4393
diff
changeset
|
56 Toolbox::WriteStyledJson(g, c); |
4393
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
57 ASSERT_EQ(f, g); |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
58 |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
59 /** |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
60 * Check compatibility with the serialized string generated by |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
61 * JsonCpp 1.7.4 (Ubuntu 18.04). "StripSpaces()" removes the |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
62 * trailing end-of-line character that was not present in the |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
63 * deprecated serialization classes of JsonCpp. |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
64 **/ |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
65 ASSERT_EQ(Toolbox::StripSpaces(d), "{\"hello\":\"world\"}"); |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
66 ASSERT_EQ(Toolbox::StripSpaces(f), "{\n \"hello\" : \"world\"\n}"); |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
67 } |
e8e95b80194f
removing usage of deprecated JsonCpp classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
68 |
4397
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
69 TEST(Toolbox, JsonComments) |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
70 { |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
71 std::string a = "/* a */ { /* b */ \"hello\" : /* c */ \"world\" /* d */ } // e"; |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
72 |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
73 Json::Value b; |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
74 ASSERT_TRUE(Toolbox::ReadJsonWithoutComments(b, a)); |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
75 |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
76 std::string c; |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
77 Toolbox::WriteFastJson(c, b); |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
78 ASSERT_EQ(Toolbox::StripSpaces(c), "{\"hello\":\"world\"}"); |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
79 |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
80 Toolbox::WriteStyledJson(c, b); |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
81 ASSERT_EQ(Toolbox::StripSpaces(c), "{\n \"hello\" : \"world\"\n}"); |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
82 } |
3aeb5171fbd4
new function Toolbox::ReadJsonWithoutComments()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4394
diff
changeset
|
83 |
3373
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
84 TEST(Toolbox, Base64_allByteValues) |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
85 { |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
86 std::string toEncode; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
87 std::string base64Result; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
88 std::string decodedResult; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
89 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
90 size_t size = 2*256; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
91 toEncode.reserve(size); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
92 for (size_t i = 0; i < size; i++) |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
93 toEncode.push_back(i % 256); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
94 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
95 Toolbox::EncodeBase64(base64Result, toEncode); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
96 Toolbox::DecodeBase64(decodedResult, base64Result); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
97 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
98 ASSERT_EQ(toEncode, decodedResult); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
99 } |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
100 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
101 TEST(Toolbox, Base64_multipleSizes) |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
102 { |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
103 std::string toEncode; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
104 std::string base64Result; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
105 std::string decodedResult; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
106 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
107 for (size_t size = 0; size <= 5; size++) |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
108 { |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
109 printf("base64, testing size %zu\n", size); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
110 toEncode.clear(); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
111 toEncode.reserve(size); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
112 for (size_t i = 0; i < size; i++) |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
113 toEncode.push_back(i % 256); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
114 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
115 Toolbox::EncodeBase64(base64Result, toEncode); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
116 Toolbox::DecodeBase64(decodedResult, base64Result); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
117 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
118 ASSERT_EQ(toEncode, decodedResult); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
119 } |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
120 } |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
121 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
122 static std::string EncodeBase64Bis(const std::string& s) |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
123 { |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
124 std::string result; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
125 Toolbox::EncodeBase64(result, s); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
126 return result; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
127 } |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
128 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
129 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
130 TEST(Toolbox, Base64) |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
131 { |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
132 ASSERT_EQ("", EncodeBase64Bis("")); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
133 ASSERT_EQ("YQ==", EncodeBase64Bis("a")); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
134 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
135 const std::string hello = "SGVsbG8gd29ybGQ="; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
136 ASSERT_EQ(hello, EncodeBase64Bis("Hello world")); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
137 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
138 std::string decoded; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
139 Toolbox::DecodeBase64(decoded, hello); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
140 ASSERT_EQ("Hello world", decoded); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
141 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
142 // Invalid character |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
143 ASSERT_THROW(Toolbox::DecodeBase64(decoded, "?"), OrthancException); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
144 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
145 // All the allowed characters |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
146 Toolbox::DecodeBase64(decoded, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
147 } |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
148 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
149 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
150 #if 0 // enable only when compiling in Release with a C++ 11 compiler |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
151 #include <chrono> // I had troubles to link with boost::chrono ... |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
152 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
153 TEST(Toolbox, Base64_largeString) |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
154 { |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
155 std::string toEncode; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
156 std::string base64Result; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
157 std::string decodedResult; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
158 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
159 size_t size = 10 * 1024 * 1024; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
160 toEncode.reserve(size); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
161 for (size_t i = 0; i < size; i++) |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
162 toEncode.push_back(i % 256); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
163 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
164 std::chrono::high_resolution_clock::time_point start; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
165 std::chrono::high_resolution_clock::time_point afterEncoding; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
166 std::chrono::high_resolution_clock::time_point afterDecoding; |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
167 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
168 start = std::chrono::high_resolution_clock::now(); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
169 Orthanc::Toolbox::EncodeBase64(base64Result, toEncode); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
170 afterEncoding = std::chrono::high_resolution_clock::now(); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
171 Orthanc::Toolbox::DecodeBase64(decodedResult, base64Result); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
172 afterDecoding = std::chrono::high_resolution_clock::now(); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
173 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
174 ASSERT_EQ(toEncode, decodedResult); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
175 |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
176 printf("encoding took %zu ms\n", (std::chrono::duration_cast<std::chrono::milliseconds>(afterEncoding - start))); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
177 printf("decoding took %zu ms\n", (std::chrono::duration_cast<std::chrono::milliseconds>(afterDecoding - afterEncoding))); |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
178 } |
4a8e8a96b233
Fixed CRLF to LF in various files (found through grepping the source tree)
Benjamin Golinvaux <bgo@osimis.io>
parents:
3331
diff
changeset
|
179 #endif |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
180 |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
181 |
3608
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
182 TEST(Toolbox, LargeHexadecimalToDecimal) |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
183 { |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
184 // https://stackoverflow.com/a/16967286/881731 |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
185 ASSERT_EQ( |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
186 "166089946137986168535368849184301740204613753693156360462575217560130904921953976324839782808018277000296027060873747803291797869684516494894741699267674246881622658654267131250470956587908385447044319923040838072975636163137212887824248575510341104029461758594855159174329892125993844566497176102668262139513", |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
187 Toolbox::LargeHexadecimalToDecimal("EC851A69B8ACD843164E10CFF70CF9E86DC2FEE3CF6F374B43C854E3342A2F1AC3E30C741CC41E679DF6D07CE6FA3A66083EC9B8C8BF3AF05D8BDBB0AA6Cb3ef8c5baa2a5e531ba9e28592f99e0fe4f95169a6c63f635d0197e325c5ec76219b907e4ebdcd401fb1986e4e3ca661ff73e7e2b8fd9988e753b7042b2bbca76679")); |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
188 |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
189 ASSERT_EQ("0", Toolbox::LargeHexadecimalToDecimal("")); |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
190 ASSERT_EQ("0", Toolbox::LargeHexadecimalToDecimal("0")); |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
191 ASSERT_EQ("0", Toolbox::LargeHexadecimalToDecimal("0000")); |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
192 ASSERT_EQ("255", Toolbox::LargeHexadecimalToDecimal("00000ff")); |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
193 |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
194 ASSERT_THROW(Toolbox::LargeHexadecimalToDecimal("g"), Orthanc::OrthancException); |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
195 } |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
196 |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
197 |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
198 TEST(Toolbox, GenerateDicomPrivateUniqueIdentifier) |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
199 { |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
200 std::string s = Toolbox::GenerateDicomPrivateUniqueIdentifier(); |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
201 ASSERT_EQ("2.25.", s.substr(0, 5)); |
7ae553d9c366
created DicomUserConnection::RequestStorageCommitment()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3373
diff
changeset
|
202 } |
3711
14b363d972a8
experimenting boost::movelib::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
203 |
14b363d972a8
experimenting boost::movelib::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3641
diff
changeset
|
204 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
205 TEST(Toolbox, UniquePtr) |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
206 { |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
207 std::unique_ptr<int> i(new int(42)); |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
208 ASSERT_EQ(42, *i); |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
209 |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
210 std::unique_ptr<SingleValueObject<int> > j(new SingleValueObject<int>(42)); |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
211 ASSERT_EQ(42, j->GetValue()); |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
212 } |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
213 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
214 TEST(Toolbox, IsSetInSet) |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
215 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
216 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
217 std::set<int> needles; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
218 std::set<int> haystack; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
219 std::set<int> missings; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
220 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
221 ASSERT_TRUE(Toolbox::IsSetInSet<int>(needles, haystack)); |
4982
40fd2a485a84
fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4938
diff
changeset
|
222 ASSERT_EQ(0u, Toolbox::GetMissingsFromSet<int>(missings, needles, haystack)); |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
223 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
224 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
225 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
226 std::set<int> needles; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
227 std::set<int> haystack; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
228 std::set<int> missings; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
229 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
230 haystack.insert(5); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
231 ASSERT_TRUE(Toolbox::IsSetInSet<int>(needles, haystack)); |
4982
40fd2a485a84
fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4938
diff
changeset
|
232 ASSERT_EQ(0u, Toolbox::GetMissingsFromSet<int>(missings, needles, haystack)); |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
233 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
234 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
235 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
236 std::set<int> needles; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
237 std::set<int> haystack; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
238 std::set<int> missings; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
239 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
240 needles.insert(5); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
241 haystack.insert(5); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
242 ASSERT_TRUE(Toolbox::IsSetInSet<int>(needles, haystack)); |
4982
40fd2a485a84
fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4938
diff
changeset
|
243 ASSERT_EQ(0u, Toolbox::GetMissingsFromSet<int>(missings, needles, haystack)); |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
244 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
245 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
246 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
247 std::set<int> needles; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
248 std::set<int> haystack; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
249 std::set<int> missings; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
250 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
251 needles.insert(5); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
252 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
253 ASSERT_FALSE(Toolbox::IsSetInSet<int>(needles, haystack)); |
4982
40fd2a485a84
fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4938
diff
changeset
|
254 ASSERT_EQ(1u, Toolbox::GetMissingsFromSet<int>(missings, needles, haystack)); |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
255 ASSERT_TRUE(missings.count(5) == 1); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
256 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
257 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
258 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
259 std::set<int> needles; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
260 std::set<int> haystack; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
261 std::set<int> missings; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
262 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
263 needles.insert(6); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
264 haystack.insert(5); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
265 ASSERT_FALSE(Toolbox::IsSetInSet<int>(needles, haystack)); |
4982
40fd2a485a84
fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4938
diff
changeset
|
266 ASSERT_EQ(1u, Toolbox::GetMissingsFromSet<int>(missings, needles, haystack)); |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
267 ASSERT_TRUE(missings.count(6) == 1); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
268 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
269 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
270 { |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
271 std::set<int> needles; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
272 std::set<int> haystack; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
273 std::set<int> missings; |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
274 |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
275 needles.insert(5); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
276 needles.insert(6); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
277 haystack.insert(5); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
278 haystack.insert(6); |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
279 ASSERT_TRUE(Toolbox::IsSetInSet<int>(needles, haystack)); |
4982
40fd2a485a84
fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4938
diff
changeset
|
280 ASSERT_EQ(0u, Toolbox::GetMissingsFromSet<int>(missings, needles, haystack)); |
4936
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
281 } |
8422e4f99a18
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
Alain Mazy <am@osimis.io>
parents:
4870
diff
changeset
|
282 } |
4938
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
283 |
5379 | 284 TEST(Toolbox, GetSetIntersection) |
285 { | |
286 { | |
287 std::set<int> target; | |
288 std::set<int> a; | |
289 std::set<int> b; | |
290 | |
291 Toolbox::GetIntersection(target, a, b); | |
292 ASSERT_EQ(0u, target.size()); | |
293 } | |
294 | |
295 { | |
296 std::set<int> target; | |
297 std::set<int> a; | |
298 std::set<int> b; | |
299 | |
300 a.insert(1); | |
301 b.insert(1); | |
302 | |
303 Toolbox::GetIntersection(target, a, b); | |
304 ASSERT_EQ(1u, target.size()); | |
305 ASSERT_EQ(1u, target.count(1)); | |
306 } | |
307 | |
308 { | |
309 std::set<int> target; | |
310 std::set<int> a; | |
311 std::set<int> b; | |
312 | |
313 a.insert(1); | |
314 a.insert(2); | |
315 b.insert(2); | |
316 | |
317 Toolbox::GetIntersection(target, a, b); | |
318 ASSERT_EQ(1u, target.size()); | |
319 ASSERT_EQ(0u, target.count(1)); | |
320 ASSERT_EQ(1u, target.count(2)); | |
321 } | |
322 | |
323 } | |
324 | |
325 | |
4938
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
326 TEST(Toolbox, JoinStrings) |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
327 { |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
328 { |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
329 std::set<std::string> source; |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
330 std::string result; |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
331 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
332 Toolbox::JoinStrings(result, source, ";"); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
333 ASSERT_EQ("", result); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
334 } |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
335 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
336 { |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
337 std::set<std::string> source; |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
338 source.insert("1"); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
339 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
340 std::string result; |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
341 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
342 Toolbox::JoinStrings(result, source, ";"); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
343 ASSERT_EQ("1", result); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
344 } |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
345 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
346 { |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
347 std::set<std::string> source; |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
348 source.insert("2"); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
349 source.insert("1"); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
350 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
351 std::string result; |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
352 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
353 Toolbox::JoinStrings(result, source, ";"); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
354 ASSERT_EQ("1;2", result); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
355 } |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
356 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
357 { |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
358 std::set<std::string> source; |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
359 source.insert("2"); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
360 source.insert("1"); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
361 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
362 std::string result; |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
363 |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
364 Toolbox::JoinStrings(result, source, "\\"); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
365 ASSERT_EQ("1\\2", result); |
f630796a59b1
ExpandResource now able to return computed tags (like ModalitiesInStudies)
Alain Mazy <am@osimis.io>
parents:
4936
diff
changeset
|
366 } |
4982
40fd2a485a84
fix build for older compilers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4938
diff
changeset
|
367 } |
5143
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
368 |
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
369 TEST(Toolbox, JoinUri) |
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
370 { |
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
371 ASSERT_EQ("https://test.org/path", Toolbox::JoinUri("https://test.org", "path")); |
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
372 ASSERT_EQ("https://test.org/path", Toolbox::JoinUri("https://test.org/", "path")); |
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
373 ASSERT_EQ("https://test.org/path", Toolbox::JoinUri("https://test.org", "/path")); |
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
374 ASSERT_EQ("https://test.org/path", Toolbox::JoinUri("https://test.org/", "/path")); |
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
375 |
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
376 ASSERT_EQ("http://test.org:8042", Toolbox::JoinUri("http://test.org:8042", "")); |
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
377 ASSERT_EQ("http://test.org:8042/", Toolbox::JoinUri("http://test.org:8042/", "")); |
5430
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
378 } |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
379 |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
380 TEST(Toolbox, GetHumanFileSize) |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
381 { |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
382 ASSERT_EQ("234bytes", Toolbox::GetHumanFileSize(234)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
383 ASSERT_EQ("2.29KB", Toolbox::GetHumanFileSize(2345)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
384 ASSERT_EQ("22.91KB", Toolbox::GetHumanFileSize(23456)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
385 ASSERT_EQ("229.07KB", Toolbox::GetHumanFileSize(234567)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
386 ASSERT_EQ("2.24MB", Toolbox::GetHumanFileSize(2345678)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
387 ASSERT_EQ("22.37MB", Toolbox::GetHumanFileSize(23456789)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
388 ASSERT_EQ("223.70MB", Toolbox::GetHumanFileSize(234567890)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
389 ASSERT_EQ("2.18GB", Toolbox::GetHumanFileSize(2345678901)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
390 ASSERT_EQ("21.33TB", Toolbox::GetHumanFileSize(23456789012345)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
391 } |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
392 |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
393 TEST(Toolbox, GetHumanDuration) |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
394 { |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
395 ASSERT_EQ("234ns", Toolbox::GetHumanDuration(234)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
396 ASSERT_EQ("2.35us", Toolbox::GetHumanDuration(2345)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
397 ASSERT_EQ("23.46us", Toolbox::GetHumanDuration(23456)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
398 ASSERT_EQ("234.57us", Toolbox::GetHumanDuration(234567)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
399 ASSERT_EQ("2.35ms", Toolbox::GetHumanDuration(2345678)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
400 ASSERT_EQ("2.35s", Toolbox::GetHumanDuration(2345678901)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
401 ASSERT_EQ("23456.79s", Toolbox::GetHumanDuration(23456789012345)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
402 } |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
403 |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
404 TEST(Toolbox, GetHumanTransferSpeed) |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
405 { |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
406 ASSERT_EQ("8.00Mbps", Toolbox::GetHumanTransferSpeed(false, 1000, 1000000)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
407 ASSERT_EQ("8.59Gbps", Toolbox::GetHumanTransferSpeed(false, 1024*1024*1024, 1000000000)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
408 ASSERT_EQ("1.00GB in 1.00s = 8.59Gbps", Toolbox::GetHumanTransferSpeed(true, 1024*1024*1024, 1000000000)); |
b83192e7ad10
Now displaying timings when reading from/writing to disk in the verbose logs
Alain Mazy <am@osimis.io>
parents:
5379
diff
changeset
|
409 ASSERT_EQ("976.56KB in 1.00s = 8.00Mbps", Toolbox::GetHumanTransferSpeed(true, 1000*1000, 1000000000)); |
5143
95d8e0540219
avoid double '/' in HttpClient uri
Alain Mazy <am@osimis.io>
parents:
4982
diff
changeset
|
410 } |