Mercurial > hg > orthanc
annotate UnitTestsSources/UnitTestsMain.cpp @ 1394:b92de82e8869
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 29 May 2015 18:01:13 +0200 |
parents | feaf2840917c |
children | 704de8c30ff5 |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1102
diff
changeset
|
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1102
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
5 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
9 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
10 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
12 * program give permission to link the code of its release with the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
21 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
22 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
26 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
27 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
30 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
31 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
32 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
827
diff
changeset
|
33 #include "PrecompiledHeadersUnitTests.h" |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
34 #include "../Core/EnumerationDictionary.h" |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
35 |
0 | 36 #include "gtest/gtest.h" |
37 | |
38 #include <ctype.h> | |
39 | |
40 #include "../Core/Compression/ZlibCompressor.h" | |
41 #include "../Core/DicomFormat/DicomTag.h" | |
42 #include "../Core/HttpServer/HttpHandler.h" | |
63 | 43 #include "../Core/OrthancException.h" |
0 | 44 #include "../Core/Toolbox.h" |
45 #include "../Core/Uuid.h" | |
63 | 46 #include "../OrthancServer/OrthancInitialization.h" |
0 | 47 |
1337 | 48 |
63 | 49 using namespace Orthanc; |
0 | 50 |
51 | |
52 TEST(Uuid, Generation) | |
53 { | |
54 for (int i = 0; i < 10; i++) | |
55 { | |
56 std::string s = Toolbox::GenerateUuid(); | |
57 ASSERT_TRUE(Toolbox::IsUuid(s)); | |
58 } | |
59 } | |
60 | |
61 TEST(Uuid, Test) | |
62 { | |
63 ASSERT_FALSE(Toolbox::IsUuid("")); | |
64 ASSERT_FALSE(Toolbox::IsUuid("012345678901234567890123456789012345")); | |
65 ASSERT_TRUE(Toolbox::IsUuid("550e8400-e29b-41d4-a716-446655440000")); | |
708 | 66 ASSERT_FALSE(Toolbox::IsUuid("550e8400-e29b-41d4-a716-44665544000_")); |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
67 ASSERT_FALSE(Toolbox::IsUuid("01234567890123456789012345678901234_")); |
402 | 68 ASSERT_FALSE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-44665544000")); |
69 ASSERT_TRUE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-446655440000")); | |
70 ASSERT_TRUE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-446655440000 ok")); | |
71 ASSERT_FALSE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-446655440000ok")); | |
72 } | |
73 | |
74 TEST(Toolbox, IsSHA1) | |
75 { | |
76 ASSERT_FALSE(Toolbox::IsSHA1("")); | |
77 ASSERT_FALSE(Toolbox::IsSHA1("01234567890123456789012345678901234567890123")); | |
78 ASSERT_FALSE(Toolbox::IsSHA1("012345678901234567890123456789012345678901234")); | |
79 ASSERT_TRUE(Toolbox::IsSHA1("b5ed549f-956400ce-69a8c063-bf5b78be-2732a4b9")); | |
80 | |
81 std::string s; | |
82 Toolbox::ComputeSHA1(s, "The quick brown fox jumps over the lazy dog"); | |
83 ASSERT_TRUE(Toolbox::IsSHA1(s)); | |
84 ASSERT_EQ("2fd4e1c6-7a2d28fc-ed849ee1-bb76e739-1b93eb12", s); | |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
85 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
86 ASSERT_FALSE(Toolbox::IsSHA1("b5ed549f-956400ce-69a8c063-bf5b78be-2732a4b_")); |
0 | 87 } |
88 | |
708 | 89 static void StringToVector(std::vector<uint8_t>& v, |
90 const std::string& s) | |
91 { | |
92 v.resize(s.size()); | |
93 for (size_t i = 0; i < s.size(); i++) | |
94 v[i] = s[i]; | |
95 } | |
96 | |
97 | |
0 | 98 TEST(Zlib, Basic) |
99 { | |
100 std::string s = Toolbox::GenerateUuid(); | |
101 s = s + s + s + s; | |
102 | |
708 | 103 std::string compressed, compressed2; |
104 ZlibCompressor c; | |
105 c.Compress(compressed, s); | |
106 | |
107 std::vector<uint8_t> v, vv; | |
108 StringToVector(v, s); | |
109 c.Compress(compressed2, v); | |
110 ASSERT_EQ(compressed, compressed2); | |
111 | |
112 std::string uncompressed; | |
113 c.Uncompress(uncompressed, compressed); | |
114 ASSERT_EQ(s.size(), uncompressed.size()); | |
115 ASSERT_EQ(0, memcmp(&s[0], &uncompressed[0], s.size())); | |
116 | |
117 StringToVector(vv, compressed); | |
118 c.Uncompress(uncompressed, vv); | |
119 ASSERT_EQ(s.size(), uncompressed.size()); | |
120 ASSERT_EQ(0, memcmp(&s[0], &uncompressed[0], s.size())); | |
121 } | |
122 | |
123 | |
124 TEST(Zlib, Level) | |
125 { | |
126 std::string s = Toolbox::GenerateUuid(); | |
127 s = s + s + s + s; | |
128 | |
129 std::string compressed, compressed2; | |
130 ZlibCompressor c; | |
131 c.SetCompressionLevel(9); | |
132 c.Compress(compressed, s); | |
133 | |
134 c.SetCompressionLevel(0); | |
135 c.Compress(compressed2, s); | |
136 | |
137 ASSERT_TRUE(compressed.size() < compressed2.size()); | |
138 } | |
139 | |
140 | |
727 | 141 TEST(Zlib, DISABLED_Corrupted) // Disabled because it may result in a crash |
708 | 142 { |
143 std::string s = Toolbox::GenerateUuid(); | |
144 s = s + s + s + s; | |
145 | |
0 | 146 std::string compressed; |
147 ZlibCompressor c; | |
148 c.Compress(compressed, s); | |
149 | |
708 | 150 compressed[compressed.size() - 1] = 'a'; |
151 std::string u; | |
0 | 152 |
708 | 153 ASSERT_THROW(c.Uncompress(u, compressed), OrthancException); |
0 | 154 } |
155 | |
708 | 156 |
0 | 157 TEST(Zlib, Empty) |
158 { | |
159 std::string s = ""; | |
708 | 160 std::vector<uint8_t> v, vv; |
0 | 161 |
708 | 162 std::string compressed, compressed2; |
0 | 163 ZlibCompressor c; |
164 c.Compress(compressed, s); | |
708 | 165 c.Compress(compressed2, v); |
166 ASSERT_EQ(compressed, compressed2); | |
0 | 167 |
168 std::string uncompressed; | |
169 c.Uncompress(uncompressed, compressed); | |
708 | 170 ASSERT_EQ(0u, uncompressed.size()); |
0 | 171 |
708 | 172 StringToVector(vv, compressed); |
173 c.Uncompress(uncompressed, vv); | |
0 | 174 ASSERT_EQ(0u, uncompressed.size()); |
175 } | |
176 | |
708 | 177 |
912
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
178 TEST(ParseGetArguments, Basic) |
0 | 179 { |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
180 HttpHandler::GetArguments b; |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
181 HttpHandler::ParseGetArguments(b, "aaa=baaa&bb=a&aa=c"); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
182 |
0 | 183 HttpHandler::Arguments a; |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
184 HttpHandler::CompileGetArguments(a, b); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
185 |
0 | 186 ASSERT_EQ(3u, a.size()); |
187 ASSERT_EQ(a["aaa"], "baaa"); | |
188 ASSERT_EQ(a["bb"], "a"); | |
189 ASSERT_EQ(a["aa"], "c"); | |
190 } | |
191 | |
912
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
192 TEST(ParseGetArguments, BasicEmpty) |
0 | 193 { |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
194 HttpHandler::GetArguments b; |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
195 HttpHandler::ParseGetArguments(b, "aaa&bb=aa&aa"); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
196 |
0 | 197 HttpHandler::Arguments a; |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
198 HttpHandler::CompileGetArguments(a, b); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
199 |
0 | 200 ASSERT_EQ(3u, a.size()); |
201 ASSERT_EQ(a["aaa"], ""); | |
202 ASSERT_EQ(a["bb"], "aa"); | |
203 ASSERT_EQ(a["aa"], ""); | |
204 } | |
205 | |
912
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
206 TEST(ParseGetArguments, Single) |
0 | 207 { |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
208 HttpHandler::GetArguments b; |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
209 HttpHandler::ParseGetArguments(b, "aaa=baaa"); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
210 |
0 | 211 HttpHandler::Arguments a; |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
212 HttpHandler::CompileGetArguments(a, b); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
213 |
0 | 214 ASSERT_EQ(1u, a.size()); |
215 ASSERT_EQ(a["aaa"], "baaa"); | |
216 } | |
217 | |
912
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
218 TEST(ParseGetArguments, SingleEmpty) |
0 | 219 { |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
220 HttpHandler::GetArguments b; |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
221 HttpHandler::ParseGetArguments(b, "aaa"); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
222 |
0 | 223 HttpHandler::Arguments a; |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
224 HttpHandler::CompileGetArguments(a, b); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
225 |
0 | 226 ASSERT_EQ(1u, a.size()); |
227 ASSERT_EQ(a["aaa"], ""); | |
228 } | |
229 | |
912
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
230 TEST(ParseGetQuery, Test1) |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
231 { |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
232 UriComponents uri; |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
233 HttpHandler::GetArguments b; |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
234 HttpHandler::ParseGetQuery(uri, b, "/instances/test/world?aaa=baaa&bb=a&aa=c"); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
235 |
912
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
236 HttpHandler::Arguments a; |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
237 HttpHandler::CompileGetArguments(a, b); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
238 |
912
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
239 ASSERT_EQ(3u, uri.size()); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
240 ASSERT_EQ("instances", uri[0]); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
241 ASSERT_EQ("test", uri[1]); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
242 ASSERT_EQ("world", uri[2]); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
243 ASSERT_EQ(3u, a.size()); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
244 ASSERT_EQ(a["aaa"], "baaa"); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
245 ASSERT_EQ(a["bb"], "a"); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
246 ASSERT_EQ(a["aa"], "c"); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
247 } |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
248 |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
249 TEST(ParseGetQuery, Test2) |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
250 { |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
251 UriComponents uri; |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
252 HttpHandler::GetArguments b; |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
253 HttpHandler::ParseGetQuery(uri, b, "/instances/test/world"); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
254 |
912
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
255 HttpHandler::Arguments a; |
1363
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
256 HttpHandler::CompileGetArguments(a, b); |
feaf2840917c
Plugins now receive duplicated GET arguments in their REST callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1337
diff
changeset
|
257 |
912
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
258 ASSERT_EQ(3u, uri.size()); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
259 ASSERT_EQ("instances", uri[0]); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
260 ASSERT_EQ("test", uri[1]); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
261 ASSERT_EQ("world", uri[2]); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
262 ASSERT_EQ(0u, a.size()); |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
263 } |
dcb2469f00f4
PluginsHttpHandler::RestApiGet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
890
diff
changeset
|
264 |
0 | 265 TEST(Uri, SplitUriComponents) |
266 { | |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
267 UriComponents c, d; |
0 | 268 Toolbox::SplitUriComponents(c, "/cou/hello/world"); |
269 ASSERT_EQ(3u, c.size()); | |
270 ASSERT_EQ("cou", c[0]); | |
271 ASSERT_EQ("hello", c[1]); | |
272 ASSERT_EQ("world", c[2]); | |
273 | |
274 Toolbox::SplitUriComponents(c, "/cou/hello/world/"); | |
275 ASSERT_EQ(3u, c.size()); | |
276 ASSERT_EQ("cou", c[0]); | |
277 ASSERT_EQ("hello", c[1]); | |
278 ASSERT_EQ("world", c[2]); | |
279 | |
280 Toolbox::SplitUriComponents(c, "/cou/hello/world/a"); | |
281 ASSERT_EQ(4u, c.size()); | |
282 ASSERT_EQ("cou", c[0]); | |
283 ASSERT_EQ("hello", c[1]); | |
284 ASSERT_EQ("world", c[2]); | |
285 ASSERT_EQ("a", c[3]); | |
286 | |
287 Toolbox::SplitUriComponents(c, "/"); | |
288 ASSERT_EQ(0u, c.size()); | |
289 | |
290 Toolbox::SplitUriComponents(c, "/hello"); | |
291 ASSERT_EQ(1u, c.size()); | |
292 ASSERT_EQ("hello", c[0]); | |
293 | |
294 Toolbox::SplitUriComponents(c, "/hello/"); | |
295 ASSERT_EQ(1u, c.size()); | |
296 ASSERT_EQ("hello", c[0]); | |
297 | |
63 | 298 ASSERT_THROW(Toolbox::SplitUriComponents(c, ""), OrthancException); |
299 ASSERT_THROW(Toolbox::SplitUriComponents(c, "a"), OrthancException); | |
207 | 300 ASSERT_THROW(Toolbox::SplitUriComponents(c, "/coucou//coucou"), OrthancException); |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
301 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
302 c.clear(); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
303 c.push_back("test"); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
304 ASSERT_EQ("/", Toolbox::FlattenUri(c, 10)); |
0 | 305 } |
306 | |
307 | |
966
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
308 TEST(Uri, Truncate) |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
309 { |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
310 UriComponents c, d; |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
311 Toolbox::SplitUriComponents(c, "/cou/hello/world"); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
312 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
313 Toolbox::TruncateUri(d, c, 0); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
314 ASSERT_EQ(3u, d.size()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
315 ASSERT_EQ("cou", d[0]); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
316 ASSERT_EQ("hello", d[1]); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
317 ASSERT_EQ("world", d[2]); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
318 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
319 Toolbox::TruncateUri(d, c, 1); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
320 ASSERT_EQ(2u, d.size()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
321 ASSERT_EQ("hello", d[0]); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
322 ASSERT_EQ("world", d[1]); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
323 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
324 Toolbox::TruncateUri(d, c, 2); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
325 ASSERT_EQ(1u, d.size()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
326 ASSERT_EQ("world", d[0]); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
327 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
328 Toolbox::TruncateUri(d, c, 3); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
329 ASSERT_EQ(0u, d.size()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
330 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
331 Toolbox::TruncateUri(d, c, 4); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
332 ASSERT_EQ(0u, d.size()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
333 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
334 Toolbox::TruncateUri(d, c, 5); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
335 ASSERT_EQ(0u, d.size()); |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
336 } |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
337 |
886652370ff2
accelerating REST API matching
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
338 |
0 | 339 TEST(Uri, Child) |
340 { | |
341 UriComponents c1; Toolbox::SplitUriComponents(c1, "/hello/world"); | |
342 UriComponents c2; Toolbox::SplitUriComponents(c2, "/hello/hello"); | |
343 UriComponents c3; Toolbox::SplitUriComponents(c3, "/hello"); | |
344 UriComponents c4; Toolbox::SplitUriComponents(c4, "/world"); | |
345 UriComponents c5; Toolbox::SplitUriComponents(c5, "/"); | |
346 | |
347 ASSERT_TRUE(Toolbox::IsChildUri(c1, c1)); | |
348 ASSERT_FALSE(Toolbox::IsChildUri(c1, c2)); | |
349 ASSERT_FALSE(Toolbox::IsChildUri(c1, c3)); | |
350 ASSERT_FALSE(Toolbox::IsChildUri(c1, c4)); | |
351 ASSERT_FALSE(Toolbox::IsChildUri(c1, c5)); | |
352 | |
353 ASSERT_FALSE(Toolbox::IsChildUri(c2, c1)); | |
354 ASSERT_TRUE(Toolbox::IsChildUri(c2, c2)); | |
355 ASSERT_FALSE(Toolbox::IsChildUri(c2, c3)); | |
356 ASSERT_FALSE(Toolbox::IsChildUri(c2, c4)); | |
357 ASSERT_FALSE(Toolbox::IsChildUri(c2, c5)); | |
358 | |
359 ASSERT_TRUE(Toolbox::IsChildUri(c3, c1)); | |
360 ASSERT_TRUE(Toolbox::IsChildUri(c3, c2)); | |
361 ASSERT_TRUE(Toolbox::IsChildUri(c3, c3)); | |
362 ASSERT_FALSE(Toolbox::IsChildUri(c3, c4)); | |
363 ASSERT_FALSE(Toolbox::IsChildUri(c3, c5)); | |
364 | |
365 ASSERT_FALSE(Toolbox::IsChildUri(c4, c1)); | |
366 ASSERT_FALSE(Toolbox::IsChildUri(c4, c2)); | |
367 ASSERT_FALSE(Toolbox::IsChildUri(c4, c3)); | |
368 ASSERT_TRUE(Toolbox::IsChildUri(c4, c4)); | |
369 ASSERT_FALSE(Toolbox::IsChildUri(c4, c5)); | |
370 | |
371 ASSERT_TRUE(Toolbox::IsChildUri(c5, c1)); | |
372 ASSERT_TRUE(Toolbox::IsChildUri(c5, c2)); | |
373 ASSERT_TRUE(Toolbox::IsChildUri(c5, c3)); | |
374 ASSERT_TRUE(Toolbox::IsChildUri(c5, c4)); | |
375 ASSERT_TRUE(Toolbox::IsChildUri(c5, c5)); | |
376 } | |
377 | |
378 TEST(Uri, AutodetectMimeType) | |
379 { | |
380 ASSERT_EQ("", Toolbox::AutodetectMimeType("../NOTES")); | |
381 ASSERT_EQ("", Toolbox::AutodetectMimeType("")); | |
382 ASSERT_EQ("", Toolbox::AutodetectMimeType("/")); | |
383 ASSERT_EQ("", Toolbox::AutodetectMimeType("a/a")); | |
384 | |
385 ASSERT_EQ("text/plain", Toolbox::AutodetectMimeType("../NOTES.txt")); | |
386 ASSERT_EQ("text/plain", Toolbox::AutodetectMimeType("../coucou.xml/NOTES.txt")); | |
387 ASSERT_EQ("text/xml", Toolbox::AutodetectMimeType("../.xml")); | |
388 | |
389 ASSERT_EQ("application/javascript", Toolbox::AutodetectMimeType("NOTES.js")); | |
390 ASSERT_EQ("application/json", Toolbox::AutodetectMimeType("NOTES.json")); | |
391 ASSERT_EQ("application/pdf", Toolbox::AutodetectMimeType("NOTES.pdf")); | |
392 ASSERT_EQ("text/css", Toolbox::AutodetectMimeType("NOTES.css")); | |
393 ASSERT_EQ("text/html", Toolbox::AutodetectMimeType("NOTES.html")); | |
394 ASSERT_EQ("text/plain", Toolbox::AutodetectMimeType("NOTES.txt")); | |
395 ASSERT_EQ("text/xml", Toolbox::AutodetectMimeType("NOTES.xml")); | |
396 ASSERT_EQ("image/gif", Toolbox::AutodetectMimeType("NOTES.gif")); | |
397 ASSERT_EQ("image/jpeg", Toolbox::AutodetectMimeType("NOTES.jpg")); | |
398 ASSERT_EQ("image/jpeg", Toolbox::AutodetectMimeType("NOTES.jpeg")); | |
399 ASSERT_EQ("image/png", Toolbox::AutodetectMimeType("NOTES.png")); | |
400 } | |
401 | |
22 | 402 TEST(Toolbox, ComputeMD5) |
403 { | |
404 std::string s; | |
405 | |
406 // # echo -n "Hello" | md5sum | |
407 | |
408 Toolbox::ComputeMD5(s, "Hello"); | |
409 ASSERT_EQ("8b1a9953c4611296a827abf8c47804d7", s); | |
410 Toolbox::ComputeMD5(s, ""); | |
411 ASSERT_EQ("d41d8cd98f00b204e9800998ecf8427e", s); | |
412 } | |
413 | |
177 | 414 TEST(Toolbox, ComputeSHA1) |
415 { | |
416 std::string s; | |
417 | |
418 Toolbox::ComputeSHA1(s, "The quick brown fox jumps over the lazy dog"); | |
419 ASSERT_EQ("2fd4e1c6-7a2d28fc-ed849ee1-bb76e739-1b93eb12", s); | |
420 Toolbox::ComputeSHA1(s, ""); | |
421 ASSERT_EQ("da39a3ee-5e6b4b0d-3255bfef-95601890-afd80709", s); | |
422 } | |
423 | |
424 | |
809
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
425 static std::string EncodeBase64Bis(const std::string& s) |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
426 { |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
427 std::string result; |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
428 Toolbox::EncodeBase64(result, s); |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
429 return result; |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
430 } |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
431 |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
432 |
24 | 433 TEST(Toolbox, Base64) |
434 { | |
809
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
435 ASSERT_EQ("", EncodeBase64Bis("")); |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
436 ASSERT_EQ("YQ==", EncodeBase64Bis("a")); |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
437 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
438 const std::string hello = "SGVsbG8gd29ybGQ="; |
809
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
439 ASSERT_EQ(hello, EncodeBase64Bis("Hello world")); |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
440 |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
441 std::string decoded; |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
442 Toolbox::DecodeBase64(decoded, hello); |
8ce2f69436ca
do not return strings with base64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
443 ASSERT_EQ("Hello world", decoded); |
24 | 444 } |
445 | |
87
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
446 TEST(Toolbox, PathToExecutable) |
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
447 { |
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
448 printf("[%s]\n", Toolbox::GetPathToExecutable().c_str()); |
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
449 printf("[%s]\n", Toolbox::GetDirectoryOfExecutable().c_str()); |
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
450 } |
8517e2c44283
path to configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
451 |
247
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
452 TEST(Toolbox, StripSpaces) |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
453 { |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
454 ASSERT_EQ("", Toolbox::StripSpaces(" \t \r \n ")); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
455 ASSERT_EQ("coucou", Toolbox::StripSpaces(" coucou \t \r \n ")); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
456 ASSERT_EQ("cou cou", Toolbox::StripSpaces(" cou cou \n ")); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
457 ASSERT_EQ("c", Toolbox::StripSpaces(" \n\t c\r \n ")); |
c9b3ba0fd140
path management in zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
235
diff
changeset
|
458 } |
100
27dc762e3dc8
getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
459 |
707
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
460 TEST(Toolbox, Case) |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
461 { |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
462 std::string s = "CoU"; |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
463 std::string ss; |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
464 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
465 Toolbox::ToUpperCase(ss, s); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
466 ASSERT_EQ("COU", ss); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
467 Toolbox::ToLowerCase(ss, s); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
468 ASSERT_EQ("cou", ss); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
469 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
470 s = "CoU"; |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
471 Toolbox::ToUpperCase(s); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
472 ASSERT_EQ("COU", s); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
473 |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
474 s = "CoU"; |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
475 Toolbox::ToLowerCase(s); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
476 ASSERT_EQ("cou", s); |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
477 } |
203157cb4fde
unit tests of httpclient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
674
diff
changeset
|
478 |
100
27dc762e3dc8
getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
479 |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
480 #include <glog/logging.h> |
100
27dc762e3dc8
getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
481 |
27dc762e3dc8
getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
482 TEST(Logger, Basic) |
27dc762e3dc8
getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
483 { |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
484 LOG(INFO) << "I say hello"; |
100
27dc762e3dc8
getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
485 } |
27dc762e3dc8
getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
486 |
107
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
487 TEST(Toolbox, ConvertFromLatin1) |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
488 { |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
489 // This is a Latin-1 test string |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
490 const unsigned char data[10] = { 0xe0, 0xe9, 0xea, 0xe7, 0x26, 0xc6, 0x61, 0x62, 0x63, 0x00 }; |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
491 |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
492 /*FILE* f = fopen("/tmp/tutu", "w"); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
493 fwrite(&data[0], 9, 1, f); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
494 fclose(f);*/ |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
495 |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
496 std::string s((char*) &data[0], 10); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
497 ASSERT_EQ("&abc", Toolbox::ConvertToAscii(s)); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
498 |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
499 // Open in Emacs, then save with UTF-8 encoding, then "hexdump -C" |
949
766a57997121
enumeration for encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
930
diff
changeset
|
500 std::string utf8 = Toolbox::ConvertToUtf8(s, Encoding_Latin1); |
235 | 501 ASSERT_EQ(15u, utf8.size()); |
107
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
502 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[0])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
503 ASSERT_EQ(0xa0, static_cast<unsigned char>(utf8[1])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
504 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[2])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
505 ASSERT_EQ(0xa9, static_cast<unsigned char>(utf8[3])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
506 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[4])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
507 ASSERT_EQ(0xaa, static_cast<unsigned char>(utf8[5])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
508 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[6])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
509 ASSERT_EQ(0xa7, static_cast<unsigned char>(utf8[7])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
510 ASSERT_EQ(0x26, static_cast<unsigned char>(utf8[8])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
511 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[9])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
512 ASSERT_EQ(0x86, static_cast<unsigned char>(utf8[10])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
513 ASSERT_EQ(0x61, static_cast<unsigned char>(utf8[11])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
514 ASSERT_EQ(0x62, static_cast<unsigned char>(utf8[12])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
515 ASSERT_EQ(0x63, static_cast<unsigned char>(utf8[13])); |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
516 ASSERT_EQ(0x00, static_cast<unsigned char>(utf8[14])); // Null-terminated string |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
517 } |
3b45473c0a73
replace boost::locale with iconv for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
102
diff
changeset
|
518 |
336 | 519 TEST(Toolbox, UrlDecode) |
520 { | |
521 std::string s; | |
522 | |
523 s = "Hello%20World"; | |
524 Toolbox::UrlDecode(s); | |
525 ASSERT_EQ("Hello World", s); | |
526 | |
337 | 527 s = "%21%23%24%26%27%28%29%2A%2B%2c%2f%3A%3b%3d%3f%40%5B%5D%90%ff"; |
336 | 528 Toolbox::UrlDecode(s); |
337 | 529 std::string ss = "!#$&'()*+,/:;=?@[]"; |
530 ss.push_back((char) 144); | |
531 ss.push_back((char) 255); | |
532 ASSERT_EQ(ss, s); | |
336 | 533 |
534 s = "(2000%2C00A4)+Other"; | |
535 Toolbox::UrlDecode(s); | |
536 ASSERT_EQ("(2000,00A4) Other", s); | |
537 } | |
538 | |
100
27dc762e3dc8
getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
539 |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
540 #if defined(__linux) |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
541 TEST(OrthancInitialization, AbsoluteDirectory) |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
542 { |
810
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
543 ASSERT_EQ("/tmp/hello", Configuration::InterpretRelativePath("/tmp", "hello")); |
401a9633e492
configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
809
diff
changeset
|
544 ASSERT_EQ("/tmp", Configuration::InterpretRelativePath("/tmp", "/tmp")); |
429
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
545 } |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
546 #endif |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
547 |
09b3c6265a94
unit test for fedora 18 problem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
402
diff
changeset
|
548 |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
549 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
550 #include "../OrthancServer/ServerEnumerations.h" |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
551 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
552 TEST(EnumerationDictionary, Simple) |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
553 { |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
554 Toolbox::EnumerationDictionary<MetadataType> d; |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
555 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
556 ASSERT_THROW(d.Translate("ReceptionDate"), OrthancException); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
557 ASSERT_EQ(MetadataType_ModifiedFrom, d.Translate("5")); |
436
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
435
diff
changeset
|
558 ASSERT_EQ(256, d.Translate("256")); |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
559 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
560 d.Add(MetadataType_Instance_ReceptionDate, "ReceptionDate"); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
561 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
562 ASSERT_EQ(MetadataType_Instance_ReceptionDate, d.Translate("ReceptionDate")); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
563 ASSERT_EQ(MetadataType_Instance_ReceptionDate, d.Translate("2")); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
564 ASSERT_EQ("ReceptionDate", d.Translate(MetadataType_Instance_ReceptionDate)); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
565 |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
566 ASSERT_THROW(d.Add(MetadataType_Instance_ReceptionDate, "Hello"), OrthancException); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
567 ASSERT_THROW(d.Add(MetadataType_ModifiedFrom, "ReceptionDate"), OrthancException); // already used |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
568 ASSERT_THROW(d.Add(MetadataType_ModifiedFrom, "1024"), OrthancException); // cannot register numbers |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
569 d.Add(MetadataType_ModifiedFrom, "ModifiedFrom"); // ok |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
570 } |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
571 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
572 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
573 TEST(EnumerationDictionary, ServerEnumerations) |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
574 { |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
575 ASSERT_STREQ("Patient", EnumerationToString(ResourceType_Patient)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
576 ASSERT_STREQ("Study", EnumerationToString(ResourceType_Study)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
577 ASSERT_STREQ("Series", EnumerationToString(ResourceType_Series)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
578 ASSERT_STREQ("Instance", EnumerationToString(ResourceType_Instance)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
579 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
580 ASSERT_STREQ("ModifiedSeries", EnumerationToString(ChangeType_ModifiedSeries)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
581 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
582 ASSERT_STREQ("Failure", EnumerationToString(StoreStatus_Failure)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
583 ASSERT_STREQ("Success", EnumerationToString(StoreStatus_Success)); |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
584 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
585 ASSERT_STREQ("CompletedSeries", EnumerationToString(ChangeType_CompletedSeries)); |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
586 |
437 | 587 ASSERT_EQ("IndexInSeries", EnumerationToString(MetadataType_Instance_IndexInSeries)); |
588 ASSERT_EQ("LastUpdate", EnumerationToString(MetadataType_LastUpdate)); | |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
589 |
559 | 590 ASSERT_EQ(ResourceType_Patient, StringToResourceType("PATienT")); |
591 ASSERT_EQ(ResourceType_Study, StringToResourceType("STudy")); | |
592 ASSERT_EQ(ResourceType_Series, StringToResourceType("SeRiEs")); | |
593 ASSERT_EQ(ResourceType_Instance, StringToResourceType("INStance")); | |
594 ASSERT_EQ(ResourceType_Instance, StringToResourceType("IMagE")); | |
595 ASSERT_THROW(StringToResourceType("heLLo"), OrthancException); | |
596 | |
435
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
597 ASSERT_EQ(2047, StringToMetadata("2047")); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
598 ASSERT_THROW(StringToMetadata("Ceci est un test"), OrthancException); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
599 ASSERT_THROW(RegisterUserMetadata(128, ""), OrthancException); // too low (< 1024) |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
600 ASSERT_THROW(RegisterUserMetadata(128000, ""), OrthancException); // too high (> 65535) |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
601 RegisterUserMetadata(2047, "Ceci est un test"); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
602 ASSERT_EQ(2047, StringToMetadata("2047")); |
28ba73274919
registration of user-defined metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
603 ASSERT_EQ(2047, StringToMetadata("Ceci est un test")); |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
604 } |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
605 |
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
430
diff
changeset
|
606 |
450 | 607 |
483
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
608 TEST(Toolbox, WriteFile) |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
609 { |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
610 std::string path; |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
611 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
612 { |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
613 Toolbox::TemporaryFile tmp; |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
614 path = tmp.GetPath(); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
615 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
616 std::string s; |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
617 s.append("Hello"); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
618 s.push_back('\0'); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
619 s.append("World"); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
620 ASSERT_EQ(11u, s.size()); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
621 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
622 Toolbox::WriteFile(s, path.c_str()); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
623 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
624 std::string t; |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
625 Toolbox::ReadFile(t, path.c_str()); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
626 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
627 ASSERT_EQ(11u, t.size()); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
628 ASSERT_EQ(0, t[5]); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
629 ASSERT_EQ(0, memcmp(s.c_str(), t.c_str(), s.size())); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
630 } |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
631 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
632 std::string u; |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
633 ASSERT_THROW(Toolbox::ReadFile(u, path.c_str()), OrthancException); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
634 } |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
635 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
476
diff
changeset
|
636 |
608 | 637 TEST(Toolbox, Wildcard) |
638 { | |
639 ASSERT_EQ("abcd", Toolbox::WildcardToRegularExpression("abcd")); | |
640 ASSERT_EQ("ab.*cd", Toolbox::WildcardToRegularExpression("ab*cd")); | |
641 ASSERT_EQ("ab..cd", Toolbox::WildcardToRegularExpression("ab??cd")); | |
642 ASSERT_EQ("a.*b.c.*d", Toolbox::WildcardToRegularExpression("a*b?c*d")); | |
643 ASSERT_EQ("a\\{b\\]", Toolbox::WildcardToRegularExpression("a{b]")); | |
644 } | |
645 | |
646 | |
647 TEST(Toolbox, Tokenize) | |
648 { | |
649 std::vector<std::string> t; | |
650 | |
651 Toolbox::TokenizeString(t, "", ','); | |
652 ASSERT_EQ(1, t.size()); | |
653 ASSERT_EQ("", t[0]); | |
654 | |
655 Toolbox::TokenizeString(t, "abc", ','); | |
656 ASSERT_EQ(1, t.size()); | |
657 ASSERT_EQ("abc", t[0]); | |
658 | |
659 Toolbox::TokenizeString(t, "ab,cd,ef,", ','); | |
660 ASSERT_EQ(4, t.size()); | |
661 ASSERT_EQ("ab", t[0]); | |
662 ASSERT_EQ("cd", t[1]); | |
663 ASSERT_EQ("ef", t[2]); | |
664 ASSERT_EQ("", t[3]); | |
665 } | |
666 | |
1086
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
667 TEST(Toolbox, Enumerations) |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
668 { |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
669 ASSERT_EQ(Encoding_Utf8, StringToEncoding(EnumerationToString(Encoding_Utf8))); |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
670 ASSERT_EQ(Encoding_Ascii, StringToEncoding(EnumerationToString(Encoding_Ascii))); |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
671 ASSERT_EQ(Encoding_Latin1, StringToEncoding(EnumerationToString(Encoding_Latin1))); |
1087 | 672 ASSERT_EQ(Encoding_Latin2, StringToEncoding(EnumerationToString(Encoding_Latin2))); |
673 ASSERT_EQ(Encoding_Latin3, StringToEncoding(EnumerationToString(Encoding_Latin3))); | |
674 ASSERT_EQ(Encoding_Latin4, StringToEncoding(EnumerationToString(Encoding_Latin4))); | |
675 ASSERT_EQ(Encoding_Latin5, StringToEncoding(EnumerationToString(Encoding_Latin5))); | |
676 ASSERT_EQ(Encoding_Cyrillic, StringToEncoding(EnumerationToString(Encoding_Cyrillic))); | |
677 ASSERT_EQ(Encoding_Arabic, StringToEncoding(EnumerationToString(Encoding_Arabic))); | |
678 ASSERT_EQ(Encoding_Greek, StringToEncoding(EnumerationToString(Encoding_Greek))); | |
679 ASSERT_EQ(Encoding_Hebrew, StringToEncoding(EnumerationToString(Encoding_Hebrew))); | |
1090
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
680 ASSERT_EQ(Encoding_Japanese, StringToEncoding(EnumerationToString(Encoding_Japanese))); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
681 ASSERT_EQ(Encoding_Chinese, StringToEncoding(EnumerationToString(Encoding_Chinese))); |
e494ceb8d763
support more encodings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1087
diff
changeset
|
682 ASSERT_EQ(Encoding_Thai, StringToEncoding(EnumerationToString(Encoding_Thai))); |
1086
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
683 |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
684 ASSERT_EQ(ResourceType_Patient, StringToResourceType(EnumerationToString(ResourceType_Patient))); |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
685 ASSERT_EQ(ResourceType_Study, StringToResourceType(EnumerationToString(ResourceType_Study))); |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
686 ASSERT_EQ(ResourceType_Series, StringToResourceType(EnumerationToString(ResourceType_Series))); |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
687 ASSERT_EQ(ResourceType_Instance, StringToResourceType(EnumerationToString(ResourceType_Instance))); |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
688 |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
689 ASSERT_EQ(ImageFormat_Png, StringToImageFormat(EnumerationToString(ImageFormat_Png))); |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
690 } |
e56c3ed8d738
Parameter to set the default encoding for DICOM files without SpecificCharacterSet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1050
diff
changeset
|
691 |
608 | 692 |
674
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
693 |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
694 #if defined(__linux) |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
695 #include <endian.h> |
1337 | 696 #elif defined(__FreeBSD__) |
697 #include <machine/endian.h> | |
674
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
698 #endif |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
699 |
1337 | 700 |
637 | 701 TEST(Toolbox, Endianness) |
702 { | |
674
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
703 // Parts of this test come from Adam Conrad |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
704 // http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728822#5 |
637 | 705 |
1337 | 706 |
707 /** | |
708 * Windows and OS X are assumed to always little-endian. | |
709 **/ | |
710 | |
711 #if defined(_WIN32) || defined(__APPLE__) | |
637 | 712 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); |
674
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
713 |
918 | 714 |
1337 | 715 /** |
716 * Linux. | |
717 **/ | |
718 | |
890 | 719 #elif defined(__linux) || defined(__FreeBSD_kernel__) |
674
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
720 |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
721 #if !defined(__BYTE_ORDER) |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
722 # error Support your platform here |
637 | 723 #endif |
724 | |
674
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
725 # if __BYTE_ORDER == __BIG_ENDIAN |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
726 ASSERT_EQ(Endianness_Big, Toolbox::DetectEndianness()); |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
727 # else // __LITTLE_ENDIAN |
637 | 728 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); |
674
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
729 # endif |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
730 |
1337 | 731 |
732 /** | |
733 * FreeBSD. | |
734 **/ | |
735 | |
736 #elif defined(__FreeBSD__) | |
737 # if _BYTE_ORDER == _BIG_ENDIAN | |
738 ASSERT_EQ(Endianness_Big, Toolbox::DetectEndianness()); | |
739 # else // _LITTLE_ENDIAN | |
740 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); | |
741 # endif | |
742 | |
674
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
743 #else |
d76b747aec1b
improved check for big endianness
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
637
diff
changeset
|
744 #error Support your platform here |
637 | 745 #endif |
746 } | |
747 | |
748 | |
1045
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
749 #if ORTHANC_PUGIXML_ENABLED == 1 |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
750 TEST(Toolbox, Xml) |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
751 { |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
752 Json::Value a; |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
753 a["hello"] = "world"; |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
754 a["42"] = 43; |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
755 a["b"] = Json::arrayValue; |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
756 a["b"].append("test"); |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
757 a["b"].append("test2"); |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
758 |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
759 std::string s; |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
760 Toolbox::JsonToXml(s, a); |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
761 |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
762 std::cout << s; |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
763 } |
1050
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
764 #endif |
1045
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
765 |
1050
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
766 |
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
767 #if !defined(_WIN32) |
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
768 TEST(Toolbox, ExecuteSystemCommand) |
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
769 { |
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
770 std::vector<std::string> args(2); |
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
771 args[0] = "Hello"; |
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
772 args[1] = "World"; |
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
773 |
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
774 Toolbox::ExecuteSystemCommand("echo", args); |
64f1842aae2e
Toolbox::ExecuteSystemCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1045
diff
changeset
|
775 } |
1045
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
776 #endif |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
777 |
0bfeeb6d340f
json to xml conversion with pugixml
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
971
diff
changeset
|
778 |
1102
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
779 TEST(Toolbox, IsInteger) |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
780 { |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
781 ASSERT_TRUE(Toolbox::IsInteger("00236")); |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
782 ASSERT_TRUE(Toolbox::IsInteger("-0042")); |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
783 ASSERT_TRUE(Toolbox::IsInteger("0")); |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
784 ASSERT_TRUE(Toolbox::IsInteger("-0")); |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
785 |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
786 ASSERT_FALSE(Toolbox::IsInteger("")); |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
787 ASSERT_FALSE(Toolbox::IsInteger("42a")); |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
788 ASSERT_FALSE(Toolbox::IsInteger("42-")); |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
789 } |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
790 |
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1090
diff
changeset
|
791 |
0 | 792 int main(int argc, char **argv) |
793 { | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
794 // Initialize Google's logging library. |
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
795 FLAGS_logtostderr = true; |
137
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
107
diff
changeset
|
796 FLAGS_minloglevel = 0; |
159
c08fbad40ddd
less verbosity in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
797 |
c08fbad40ddd
less verbosity in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
798 // Go to trace-level verbosity |
c08fbad40ddd
less verbosity in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
799 //FLAGS_v = 1; |
c08fbad40ddd
less verbosity in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
137
diff
changeset
|
800 |
453 | 801 Toolbox::DetectEndianness(); |
802 | |
102
7593b57dc1bf
switch to google log
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
101
diff
changeset
|
803 google::InitGoogleLogging("Orthanc"); |
100
27dc762e3dc8
getting rid of static dcmtk for debian
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
804 |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
805 Toolbox::CreateDirectory("UnitTestsResults"); |
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
782
diff
changeset
|
806 |
63 | 807 OrthancInitialize(); |
0 | 808 ::testing::InitGoogleTest(&argc, argv); |
809 int result = RUN_ALL_TESTS(); | |
63 | 810 OrthancFinalize(); |
0 | 811 return result; |
812 } |