comparison UnitTestsSources/main.cpp @ 632:17815b9d4280

rename the UnitTests directory to avoid clashes in filenames
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 Oct 2013 16:26:51 +0100
parents UnitTests/main.cpp@0bedf8ff9288
children 900274ed996f
comparison
equal deleted inserted replaced
631:fc6ad5b97219 632:17815b9d4280
1 #include "../Core/EnumerationDictionary.h"
2
3 #include "gtest/gtest.h"
4
5 #include <ctype.h>
6
7 #include "../Core/Compression/ZlibCompressor.h"
8 #include "../Core/DicomFormat/DicomTag.h"
9 #include "../Core/HttpServer/HttpHandler.h"
10 #include "../Core/OrthancException.h"
11 #include "../Core/Toolbox.h"
12 #include "../Core/Uuid.h"
13 #include "../OrthancServer/FromDcmtkBridge.h"
14 #include "../OrthancServer/OrthancInitialization.h"
15 #include "../Core/MultiThreading/SharedMessageQueue.h"
16
17 using namespace Orthanc;
18
19
20 TEST(Uuid, Generation)
21 {
22 for (int i = 0; i < 10; i++)
23 {
24 std::string s = Toolbox::GenerateUuid();
25 ASSERT_TRUE(Toolbox::IsUuid(s));
26 }
27 }
28
29 TEST(Uuid, Test)
30 {
31 ASSERT_FALSE(Toolbox::IsUuid(""));
32 ASSERT_FALSE(Toolbox::IsUuid("012345678901234567890123456789012345"));
33 ASSERT_TRUE(Toolbox::IsUuid("550e8400-e29b-41d4-a716-446655440000"));
34 ASSERT_FALSE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-44665544000"));
35 ASSERT_TRUE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-446655440000"));
36 ASSERT_TRUE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-446655440000 ok"));
37 ASSERT_FALSE(Toolbox::StartsWithUuid("550e8400-e29b-41d4-a716-446655440000ok"));
38 }
39
40 TEST(Toolbox, IsSHA1)
41 {
42 ASSERT_FALSE(Toolbox::IsSHA1(""));
43 ASSERT_FALSE(Toolbox::IsSHA1("01234567890123456789012345678901234567890123"));
44 ASSERT_FALSE(Toolbox::IsSHA1("012345678901234567890123456789012345678901234"));
45 ASSERT_TRUE(Toolbox::IsSHA1("b5ed549f-956400ce-69a8c063-bf5b78be-2732a4b9"));
46
47 std::string s;
48 Toolbox::ComputeSHA1(s, "The quick brown fox jumps over the lazy dog");
49 ASSERT_TRUE(Toolbox::IsSHA1(s));
50 ASSERT_EQ("2fd4e1c6-7a2d28fc-ed849ee1-bb76e739-1b93eb12", s);
51 }
52
53 TEST(Zlib, Basic)
54 {
55 std::string s = Toolbox::GenerateUuid();
56 s = s + s + s + s;
57
58 std::string compressed;
59 ZlibCompressor c;
60 c.Compress(compressed, s);
61
62 std::string uncompressed;
63 c.Uncompress(uncompressed, compressed);
64
65 ASSERT_EQ(s.size(), uncompressed.size());
66 ASSERT_EQ(0, memcmp(&s[0], &uncompressed[0], s.size()));
67 }
68
69 TEST(Zlib, Empty)
70 {
71 std::string s = "";
72
73 std::string compressed;
74 ZlibCompressor c;
75 c.Compress(compressed, s);
76
77 std::string uncompressed;
78 c.Uncompress(uncompressed, compressed);
79
80 ASSERT_EQ(0u, uncompressed.size());
81 }
82
83 TEST(ParseGetQuery, Basic)
84 {
85 HttpHandler::Arguments a;
86 HttpHandler::ParseGetQuery(a, "aaa=baaa&bb=a&aa=c");
87 ASSERT_EQ(3u, a.size());
88 ASSERT_EQ(a["aaa"], "baaa");
89 ASSERT_EQ(a["bb"], "a");
90 ASSERT_EQ(a["aa"], "c");
91 }
92
93 TEST(ParseGetQuery, BasicEmpty)
94 {
95 HttpHandler::Arguments a;
96 HttpHandler::ParseGetQuery(a, "aaa&bb=aa&aa");
97 ASSERT_EQ(3u, a.size());
98 ASSERT_EQ(a["aaa"], "");
99 ASSERT_EQ(a["bb"], "aa");
100 ASSERT_EQ(a["aa"], "");
101 }
102
103 TEST(ParseGetQuery, Single)
104 {
105 HttpHandler::Arguments a;
106 HttpHandler::ParseGetQuery(a, "aaa=baaa");
107 ASSERT_EQ(1u, a.size());
108 ASSERT_EQ(a["aaa"], "baaa");
109 }
110
111 TEST(ParseGetQuery, SingleEmpty)
112 {
113 HttpHandler::Arguments a;
114 HttpHandler::ParseGetQuery(a, "aaa");
115 ASSERT_EQ(1u, a.size());
116 ASSERT_EQ(a["aaa"], "");
117 }
118
119 TEST(DicomFormat, Tag)
120 {
121 ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010)));
122
123 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription");
124 ASSERT_EQ(0x0008, t.GetGroup());
125 ASSERT_EQ(0x103E, t.GetElement());
126
127 t = FromDcmtkBridge::ParseTag("0020-e040");
128 ASSERT_EQ(0x0020, t.GetGroup());
129 ASSERT_EQ(0xe040, t.GetElement());
130
131 // Test ==() and !=() operators
132 ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020));
133 ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020));
134 }
135
136
137 TEST(Uri, SplitUriComponents)
138 {
139 UriComponents c;
140 Toolbox::SplitUriComponents(c, "/cou/hello/world");
141 ASSERT_EQ(3u, c.size());
142 ASSERT_EQ("cou", c[0]);
143 ASSERT_EQ("hello", c[1]);
144 ASSERT_EQ("world", c[2]);
145
146 Toolbox::SplitUriComponents(c, "/cou/hello/world/");
147 ASSERT_EQ(3u, c.size());
148 ASSERT_EQ("cou", c[0]);
149 ASSERT_EQ("hello", c[1]);
150 ASSERT_EQ("world", c[2]);
151
152 Toolbox::SplitUriComponents(c, "/cou/hello/world/a");
153 ASSERT_EQ(4u, c.size());
154 ASSERT_EQ("cou", c[0]);
155 ASSERT_EQ("hello", c[1]);
156 ASSERT_EQ("world", c[2]);
157 ASSERT_EQ("a", c[3]);
158
159 Toolbox::SplitUriComponents(c, "/");
160 ASSERT_EQ(0u, c.size());
161
162 Toolbox::SplitUriComponents(c, "/hello");
163 ASSERT_EQ(1u, c.size());
164 ASSERT_EQ("hello", c[0]);
165
166 Toolbox::SplitUriComponents(c, "/hello/");
167 ASSERT_EQ(1u, c.size());
168 ASSERT_EQ("hello", c[0]);
169
170 ASSERT_THROW(Toolbox::SplitUriComponents(c, ""), OrthancException);
171 ASSERT_THROW(Toolbox::SplitUriComponents(c, "a"), OrthancException);
172 ASSERT_THROW(Toolbox::SplitUriComponents(c, "/coucou//coucou"), OrthancException);
173 }
174
175
176 TEST(Uri, Child)
177 {
178 UriComponents c1; Toolbox::SplitUriComponents(c1, "/hello/world");
179 UriComponents c2; Toolbox::SplitUriComponents(c2, "/hello/hello");
180 UriComponents c3; Toolbox::SplitUriComponents(c3, "/hello");
181 UriComponents c4; Toolbox::SplitUriComponents(c4, "/world");
182 UriComponents c5; Toolbox::SplitUriComponents(c5, "/");
183
184 ASSERT_TRUE(Toolbox::IsChildUri(c1, c1));
185 ASSERT_FALSE(Toolbox::IsChildUri(c1, c2));
186 ASSERT_FALSE(Toolbox::IsChildUri(c1, c3));
187 ASSERT_FALSE(Toolbox::IsChildUri(c1, c4));
188 ASSERT_FALSE(Toolbox::IsChildUri(c1, c5));
189
190 ASSERT_FALSE(Toolbox::IsChildUri(c2, c1));
191 ASSERT_TRUE(Toolbox::IsChildUri(c2, c2));
192 ASSERT_FALSE(Toolbox::IsChildUri(c2, c3));
193 ASSERT_FALSE(Toolbox::IsChildUri(c2, c4));
194 ASSERT_FALSE(Toolbox::IsChildUri(c2, c5));
195
196 ASSERT_TRUE(Toolbox::IsChildUri(c3, c1));
197 ASSERT_TRUE(Toolbox::IsChildUri(c3, c2));
198 ASSERT_TRUE(Toolbox::IsChildUri(c3, c3));
199 ASSERT_FALSE(Toolbox::IsChildUri(c3, c4));
200 ASSERT_FALSE(Toolbox::IsChildUri(c3, c5));
201
202 ASSERT_FALSE(Toolbox::IsChildUri(c4, c1));
203 ASSERT_FALSE(Toolbox::IsChildUri(c4, c2));
204 ASSERT_FALSE(Toolbox::IsChildUri(c4, c3));
205 ASSERT_TRUE(Toolbox::IsChildUri(c4, c4));
206 ASSERT_FALSE(Toolbox::IsChildUri(c4, c5));
207
208 ASSERT_TRUE(Toolbox::IsChildUri(c5, c1));
209 ASSERT_TRUE(Toolbox::IsChildUri(c5, c2));
210 ASSERT_TRUE(Toolbox::IsChildUri(c5, c3));
211 ASSERT_TRUE(Toolbox::IsChildUri(c5, c4));
212 ASSERT_TRUE(Toolbox::IsChildUri(c5, c5));
213 }
214
215 TEST(Uri, AutodetectMimeType)
216 {
217 ASSERT_EQ("", Toolbox::AutodetectMimeType("../NOTES"));
218 ASSERT_EQ("", Toolbox::AutodetectMimeType(""));
219 ASSERT_EQ("", Toolbox::AutodetectMimeType("/"));
220 ASSERT_EQ("", Toolbox::AutodetectMimeType("a/a"));
221
222 ASSERT_EQ("text/plain", Toolbox::AutodetectMimeType("../NOTES.txt"));
223 ASSERT_EQ("text/plain", Toolbox::AutodetectMimeType("../coucou.xml/NOTES.txt"));
224 ASSERT_EQ("text/xml", Toolbox::AutodetectMimeType("../.xml"));
225
226 ASSERT_EQ("application/javascript", Toolbox::AutodetectMimeType("NOTES.js"));
227 ASSERT_EQ("application/json", Toolbox::AutodetectMimeType("NOTES.json"));
228 ASSERT_EQ("application/pdf", Toolbox::AutodetectMimeType("NOTES.pdf"));
229 ASSERT_EQ("text/css", Toolbox::AutodetectMimeType("NOTES.css"));
230 ASSERT_EQ("text/html", Toolbox::AutodetectMimeType("NOTES.html"));
231 ASSERT_EQ("text/plain", Toolbox::AutodetectMimeType("NOTES.txt"));
232 ASSERT_EQ("text/xml", Toolbox::AutodetectMimeType("NOTES.xml"));
233 ASSERT_EQ("image/gif", Toolbox::AutodetectMimeType("NOTES.gif"));
234 ASSERT_EQ("image/jpeg", Toolbox::AutodetectMimeType("NOTES.jpg"));
235 ASSERT_EQ("image/jpeg", Toolbox::AutodetectMimeType("NOTES.jpeg"));
236 ASSERT_EQ("image/png", Toolbox::AutodetectMimeType("NOTES.png"));
237 }
238
239 TEST(Toolbox, ComputeMD5)
240 {
241 std::string s;
242
243 // # echo -n "Hello" | md5sum
244
245 Toolbox::ComputeMD5(s, "Hello");
246 ASSERT_EQ("8b1a9953c4611296a827abf8c47804d7", s);
247 Toolbox::ComputeMD5(s, "");
248 ASSERT_EQ("d41d8cd98f00b204e9800998ecf8427e", s);
249 }
250
251 TEST(Toolbox, ComputeSHA1)
252 {
253 std::string s;
254
255 Toolbox::ComputeSHA1(s, "The quick brown fox jumps over the lazy dog");
256 ASSERT_EQ("2fd4e1c6-7a2d28fc-ed849ee1-bb76e739-1b93eb12", s);
257 Toolbox::ComputeSHA1(s, "");
258 ASSERT_EQ("da39a3ee-5e6b4b0d-3255bfef-95601890-afd80709", s);
259 }
260
261
262 TEST(Toolbox, Base64)
263 {
264 ASSERT_EQ("", Toolbox::EncodeBase64(""));
265 ASSERT_EQ("YQ==", Toolbox::EncodeBase64("a"));
266 ASSERT_EQ("SGVsbG8gd29ybGQ=", Toolbox::EncodeBase64("Hello world"));
267 }
268
269 TEST(Toolbox, PathToExecutable)
270 {
271 printf("[%s]\n", Toolbox::GetPathToExecutable().c_str());
272 printf("[%s]\n", Toolbox::GetDirectoryOfExecutable().c_str());
273 }
274
275 TEST(Toolbox, StripSpaces)
276 {
277 ASSERT_EQ("", Toolbox::StripSpaces(" \t \r \n "));
278 ASSERT_EQ("coucou", Toolbox::StripSpaces(" coucou \t \r \n "));
279 ASSERT_EQ("cou cou", Toolbox::StripSpaces(" cou cou \n "));
280 ASSERT_EQ("c", Toolbox::StripSpaces(" \n\t c\r \n "));
281 }
282
283
284 #include <glog/logging.h>
285
286 TEST(Logger, Basic)
287 {
288 LOG(INFO) << "I say hello";
289 }
290
291 TEST(Toolbox, ConvertFromLatin1)
292 {
293 // This is a Latin-1 test string
294 const unsigned char data[10] = { 0xe0, 0xe9, 0xea, 0xe7, 0x26, 0xc6, 0x61, 0x62, 0x63, 0x00 };
295
296 /*FILE* f = fopen("/tmp/tutu", "w");
297 fwrite(&data[0], 9, 1, f);
298 fclose(f);*/
299
300 std::string s((char*) &data[0], 10);
301 ASSERT_EQ("&abc", Toolbox::ConvertToAscii(s));
302
303 // Open in Emacs, then save with UTF-8 encoding, then "hexdump -C"
304 std::string utf8 = Toolbox::ConvertToUtf8(s, "ISO-8859-1");
305 ASSERT_EQ(15u, utf8.size());
306 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[0]));
307 ASSERT_EQ(0xa0, static_cast<unsigned char>(utf8[1]));
308 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[2]));
309 ASSERT_EQ(0xa9, static_cast<unsigned char>(utf8[3]));
310 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[4]));
311 ASSERT_EQ(0xaa, static_cast<unsigned char>(utf8[5]));
312 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[6]));
313 ASSERT_EQ(0xa7, static_cast<unsigned char>(utf8[7]));
314 ASSERT_EQ(0x26, static_cast<unsigned char>(utf8[8]));
315 ASSERT_EQ(0xc3, static_cast<unsigned char>(utf8[9]));
316 ASSERT_EQ(0x86, static_cast<unsigned char>(utf8[10]));
317 ASSERT_EQ(0x61, static_cast<unsigned char>(utf8[11]));
318 ASSERT_EQ(0x62, static_cast<unsigned char>(utf8[12]));
319 ASSERT_EQ(0x63, static_cast<unsigned char>(utf8[13]));
320 ASSERT_EQ(0x00, static_cast<unsigned char>(utf8[14])); // Null-terminated string
321 }
322
323 TEST(Toolbox, UrlDecode)
324 {
325 std::string s;
326
327 s = "Hello%20World";
328 Toolbox::UrlDecode(s);
329 ASSERT_EQ("Hello World", s);
330
331 s = "%21%23%24%26%27%28%29%2A%2B%2c%2f%3A%3b%3d%3f%40%5B%5D%90%ff";
332 Toolbox::UrlDecode(s);
333 std::string ss = "!#$&'()*+,/:;=?@[]";
334 ss.push_back((char) 144);
335 ss.push_back((char) 255);
336 ASSERT_EQ(ss, s);
337
338 s = "(2000%2C00A4)+Other";
339 Toolbox::UrlDecode(s);
340 ASSERT_EQ("(2000,00A4) Other", s);
341 }
342
343
344 #if defined(__linux)
345 TEST(OrthancInitialization, AbsoluteDirectory)
346 {
347 ASSERT_EQ("/tmp/hello", InterpretRelativePath("/tmp", "hello"));
348 ASSERT_EQ("/tmp", InterpretRelativePath("/tmp", "/tmp"));
349 }
350 #endif
351
352
353
354 #include "../OrthancServer/ServerEnumerations.h"
355
356 TEST(EnumerationDictionary, Simple)
357 {
358 Toolbox::EnumerationDictionary<MetadataType> d;
359
360 ASSERT_THROW(d.Translate("ReceptionDate"), OrthancException);
361 ASSERT_EQ(MetadataType_ModifiedFrom, d.Translate("5"));
362 ASSERT_EQ(256, d.Translate("256"));
363
364 d.Add(MetadataType_Instance_ReceptionDate, "ReceptionDate");
365
366 ASSERT_EQ(MetadataType_Instance_ReceptionDate, d.Translate("ReceptionDate"));
367 ASSERT_EQ(MetadataType_Instance_ReceptionDate, d.Translate("2"));
368 ASSERT_EQ("ReceptionDate", d.Translate(MetadataType_Instance_ReceptionDate));
369
370 ASSERT_THROW(d.Add(MetadataType_Instance_ReceptionDate, "Hello"), OrthancException);
371 ASSERT_THROW(d.Add(MetadataType_ModifiedFrom, "ReceptionDate"), OrthancException); // already used
372 ASSERT_THROW(d.Add(MetadataType_ModifiedFrom, "1024"), OrthancException); // cannot register numbers
373 d.Add(MetadataType_ModifiedFrom, "ModifiedFrom"); // ok
374 }
375
376
377 TEST(EnumerationDictionary, ServerEnumerations)
378 {
379 ASSERT_STREQ("Patient", EnumerationToString(ResourceType_Patient));
380 ASSERT_STREQ("Study", EnumerationToString(ResourceType_Study));
381 ASSERT_STREQ("Series", EnumerationToString(ResourceType_Series));
382 ASSERT_STREQ("Instance", EnumerationToString(ResourceType_Instance));
383
384 ASSERT_STREQ("ModifiedSeries", EnumerationToString(ChangeType_ModifiedSeries));
385
386 ASSERT_STREQ("Failure", EnumerationToString(StoreStatus_Failure));
387 ASSERT_STREQ("Success", EnumerationToString(StoreStatus_Success));
388
389 ASSERT_STREQ("CompletedSeries", EnumerationToString(ChangeType_CompletedSeries));
390
391 ASSERT_EQ("IndexInSeries", EnumerationToString(MetadataType_Instance_IndexInSeries));
392 ASSERT_EQ("LastUpdate", EnumerationToString(MetadataType_LastUpdate));
393
394 ASSERT_EQ(ResourceType_Patient, StringToResourceType("PATienT"));
395 ASSERT_EQ(ResourceType_Study, StringToResourceType("STudy"));
396 ASSERT_EQ(ResourceType_Series, StringToResourceType("SeRiEs"));
397 ASSERT_EQ(ResourceType_Instance, StringToResourceType("INStance"));
398 ASSERT_EQ(ResourceType_Instance, StringToResourceType("IMagE"));
399 ASSERT_THROW(StringToResourceType("heLLo"), OrthancException);
400
401 ASSERT_EQ(2047, StringToMetadata("2047"));
402 ASSERT_THROW(StringToMetadata("Ceci est un test"), OrthancException);
403 ASSERT_THROW(RegisterUserMetadata(128, ""), OrthancException); // too low (< 1024)
404 ASSERT_THROW(RegisterUserMetadata(128000, ""), OrthancException); // too high (> 65535)
405 RegisterUserMetadata(2047, "Ceci est un test");
406 ASSERT_EQ(2047, StringToMetadata("2047"));
407 ASSERT_EQ(2047, StringToMetadata("Ceci est un test"));
408 }
409
410
411
412 class DynamicInteger : public IDynamicObject
413 {
414 private:
415 int value_;
416
417 public:
418 DynamicInteger(int value) : value_(value)
419 {
420 }
421
422 int GetValue() const
423 {
424 return value_;
425 }
426 };
427
428
429 TEST(SharedMessageQueue, Basic)
430 {
431 SharedMessageQueue q;
432 ASSERT_TRUE(q.WaitEmpty(0));
433 q.Enqueue(new DynamicInteger(10));
434 ASSERT_FALSE(q.WaitEmpty(1));
435 q.Enqueue(new DynamicInteger(20));
436 q.Enqueue(new DynamicInteger(30));
437 q.Enqueue(new DynamicInteger(40));
438
439 std::auto_ptr<DynamicInteger> i;
440 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(10, i->GetValue());
441 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(20, i->GetValue());
442 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(30, i->GetValue());
443 ASSERT_FALSE(q.WaitEmpty(1));
444 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(40, i->GetValue());
445 ASSERT_TRUE(q.WaitEmpty(0));
446 ASSERT_EQ(NULL, q.Dequeue(1));
447 }
448
449
450 TEST(SharedMessageQueue, Clean)
451 {
452 try
453 {
454 SharedMessageQueue q;
455 q.Enqueue(new DynamicInteger(10));
456 q.Enqueue(new DynamicInteger(20));
457 throw OrthancException("Nope");
458 }
459 catch (OrthancException&)
460 {
461 }
462 }
463
464
465 TEST(Toolbox, WriteFile)
466 {
467 std::string path;
468
469 {
470 Toolbox::TemporaryFile tmp;
471 path = tmp.GetPath();
472
473 std::string s;
474 s.append("Hello");
475 s.push_back('\0');
476 s.append("World");
477 ASSERT_EQ(11u, s.size());
478
479 Toolbox::WriteFile(s, path.c_str());
480
481 std::string t;
482 Toolbox::ReadFile(t, path.c_str());
483
484 ASSERT_EQ(11u, t.size());
485 ASSERT_EQ(0, t[5]);
486 ASSERT_EQ(0, memcmp(s.c_str(), t.c_str(), s.size()));
487 }
488
489 std::string u;
490 ASSERT_THROW(Toolbox::ReadFile(u, path.c_str()), OrthancException);
491 }
492
493
494 TEST(Toolbox, Wildcard)
495 {
496 ASSERT_EQ("abcd", Toolbox::WildcardToRegularExpression("abcd"));
497 ASSERT_EQ("ab.*cd", Toolbox::WildcardToRegularExpression("ab*cd"));
498 ASSERT_EQ("ab..cd", Toolbox::WildcardToRegularExpression("ab??cd"));
499 ASSERT_EQ("a.*b.c.*d", Toolbox::WildcardToRegularExpression("a*b?c*d"));
500 ASSERT_EQ("a\\{b\\]", Toolbox::WildcardToRegularExpression("a{b]"));
501 }
502
503
504 TEST(Toolbox, Tokenize)
505 {
506 std::vector<std::string> t;
507
508 Toolbox::TokenizeString(t, "", ',');
509 ASSERT_EQ(1, t.size());
510 ASSERT_EQ("", t[0]);
511
512 Toolbox::TokenizeString(t, "abc", ',');
513 ASSERT_EQ(1, t.size());
514 ASSERT_EQ("abc", t[0]);
515
516 Toolbox::TokenizeString(t, "ab,cd,ef,", ',');
517 ASSERT_EQ(4, t.size());
518 ASSERT_EQ("ab", t[0]);
519 ASSERT_EQ("cd", t[1]);
520 ASSERT_EQ("ef", t[2]);
521 ASSERT_EQ("", t[3]);
522 }
523
524
525 int main(int argc, char **argv)
526 {
527 // Initialize Google's logging library.
528 FLAGS_logtostderr = true;
529 FLAGS_minloglevel = 0;
530
531 // Go to trace-level verbosity
532 //FLAGS_v = 1;
533
534 Toolbox::DetectEndianness();
535
536 google::InitGoogleLogging("Orthanc");
537
538 OrthancInitialize();
539 ::testing::InitGoogleTest(&argc, argv);
540 int result = RUN_ALL_TESTS();
541 OrthancFinalize();
542 return result;
543 }