Mercurial > hg > orthanc
comparison UnitTestsSources/UnitTestsMain.cpp @ 930:27d256e0b458 mac
integration mainline -> mac
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 24 Jun 2014 16:47:18 +0200 |
parents | ac8f68cbdbb6 816dccaeb7cf |
children | 3fb427ac3f53 e57e08ed510f 766a57997121 |
comparison
equal
deleted
inserted
replaced
928:882833632b1f | 930:27d256e0b458 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, | |
4 * Belgium | |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
22 * | |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
33 #include "PrecompiledHeadersUnitTests.h" | |
1 #include "../Core/EnumerationDictionary.h" | 34 #include "../Core/EnumerationDictionary.h" |
2 | 35 |
3 #include "gtest/gtest.h" | 36 #include "gtest/gtest.h" |
4 | 37 |
5 #include <ctype.h> | 38 #include <ctype.h> |
8 #include "../Core/DicomFormat/DicomTag.h" | 41 #include "../Core/DicomFormat/DicomTag.h" |
9 #include "../Core/HttpServer/HttpHandler.h" | 42 #include "../Core/HttpServer/HttpHandler.h" |
10 #include "../Core/OrthancException.h" | 43 #include "../Core/OrthancException.h" |
11 #include "../Core/Toolbox.h" | 44 #include "../Core/Toolbox.h" |
12 #include "../Core/Uuid.h" | 45 #include "../Core/Uuid.h" |
13 #include "../OrthancServer/FromDcmtkBridge.h" | |
14 #include "../OrthancServer/OrthancInitialization.h" | 46 #include "../OrthancServer/OrthancInitialization.h" |
15 | 47 |
16 using namespace Orthanc; | 48 using namespace Orthanc; |
17 | 49 |
18 | 50 |
175 HttpHandler::Arguments a; | 207 HttpHandler::Arguments a; |
176 HttpHandler::ParseGetQuery(a, "aaa"); | 208 HttpHandler::ParseGetQuery(a, "aaa"); |
177 ASSERT_EQ(1u, a.size()); | 209 ASSERT_EQ(1u, a.size()); |
178 ASSERT_EQ(a["aaa"], ""); | 210 ASSERT_EQ(a["aaa"], ""); |
179 } | 211 } |
180 | |
181 TEST(DicomFormat, Tag) | |
182 { | |
183 ASSERT_EQ("PatientName", FromDcmtkBridge::GetName(DicomTag(0x0010, 0x0010))); | |
184 | |
185 DicomTag t = FromDcmtkBridge::ParseTag("SeriesDescription"); | |
186 ASSERT_EQ(0x0008, t.GetGroup()); | |
187 ASSERT_EQ(0x103E, t.GetElement()); | |
188 | |
189 t = FromDcmtkBridge::ParseTag("0020-e040"); | |
190 ASSERT_EQ(0x0020, t.GetGroup()); | |
191 ASSERT_EQ(0xe040, t.GetElement()); | |
192 | |
193 // Test ==() and !=() operators | |
194 ASSERT_TRUE(DICOM_TAG_PATIENT_ID == DicomTag(0x0010, 0x0020)); | |
195 ASSERT_FALSE(DICOM_TAG_PATIENT_ID != DicomTag(0x0010, 0x0020)); | |
196 } | |
197 | |
198 | 212 |
199 TEST(Uri, SplitUriComponents) | 213 TEST(Uri, SplitUriComponents) |
200 { | 214 { |
201 UriComponents c; | 215 UriComponents c; |
202 Toolbox::SplitUriComponents(c, "/cou/hello/world"); | 216 Toolbox::SplitUriComponents(c, "/cou/hello/world"); |
323 Toolbox::ComputeSHA1(s, ""); | 337 Toolbox::ComputeSHA1(s, ""); |
324 ASSERT_EQ("da39a3ee-5e6b4b0d-3255bfef-95601890-afd80709", s); | 338 ASSERT_EQ("da39a3ee-5e6b4b0d-3255bfef-95601890-afd80709", s); |
325 } | 339 } |
326 | 340 |
327 | 341 |
342 static std::string EncodeBase64Bis(const std::string& s) | |
343 { | |
344 std::string result; | |
345 Toolbox::EncodeBase64(result, s); | |
346 return result; | |
347 } | |
348 | |
349 | |
328 TEST(Toolbox, Base64) | 350 TEST(Toolbox, Base64) |
329 { | 351 { |
330 ASSERT_EQ("", Toolbox::EncodeBase64("")); | 352 ASSERT_EQ("", EncodeBase64Bis("")); |
331 ASSERT_EQ("YQ==", Toolbox::EncodeBase64("a")); | 353 ASSERT_EQ("YQ==", EncodeBase64Bis("a")); |
332 | 354 |
333 const std::string hello = "SGVsbG8gd29ybGQ="; | 355 const std::string hello = "SGVsbG8gd29ybGQ="; |
334 ASSERT_EQ(hello, Toolbox::EncodeBase64("Hello world")); | 356 ASSERT_EQ(hello, EncodeBase64Bis("Hello world")); |
335 ASSERT_EQ("Hello world", Toolbox::DecodeBase64(hello)); | 357 |
358 std::string decoded; | |
359 Toolbox::DecodeBase64(decoded, hello); | |
360 ASSERT_EQ("Hello world", decoded); | |
336 } | 361 } |
337 | 362 |
338 TEST(Toolbox, PathToExecutable) | 363 TEST(Toolbox, PathToExecutable) |
339 { | 364 { |
340 printf("[%s]\n", Toolbox::GetPathToExecutable().c_str()); | 365 printf("[%s]\n", Toolbox::GetPathToExecutable().c_str()); |
430 | 455 |
431 | 456 |
432 #if defined(__linux) | 457 #if defined(__linux) |
433 TEST(OrthancInitialization, AbsoluteDirectory) | 458 TEST(OrthancInitialization, AbsoluteDirectory) |
434 { | 459 { |
435 ASSERT_EQ("/tmp/hello", InterpretRelativePath("/tmp", "hello")); | 460 ASSERT_EQ("/tmp/hello", Configuration::InterpretRelativePath("/tmp", "hello")); |
436 ASSERT_EQ("/tmp", InterpretRelativePath("/tmp", "/tmp")); | 461 ASSERT_EQ("/tmp", Configuration::InterpretRelativePath("/tmp", "/tmp")); |
437 } | 462 } |
438 #endif | 463 #endif |
439 | 464 |
440 | 465 |
441 | 466 |
571 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); | 596 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); |
572 | 597 |
573 #elif defined(__APPLE__) | 598 #elif defined(__APPLE__) |
574 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); | 599 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); |
575 | 600 |
576 #elif defined(__linux) | 601 #elif defined(__linux) || defined(__FreeBSD_kernel__) |
577 | 602 |
578 #if !defined(__BYTE_ORDER) | 603 #if !defined(__BYTE_ORDER) |
579 # error Support your platform here | 604 # error Support your platform here |
580 #endif | 605 #endif |
581 | 606 |
589 #error Support your platform here | 614 #error Support your platform here |
590 #endif | 615 #endif |
591 } | 616 } |
592 | 617 |
593 | 618 |
594 | |
595 int main(int argc, char **argv) | 619 int main(int argc, char **argv) |
596 { | 620 { |
597 // Initialize Google's logging library. | 621 // Initialize Google's logging library. |
598 FLAGS_logtostderr = true; | 622 FLAGS_logtostderr = true; |
599 FLAGS_minloglevel = 0; | 623 FLAGS_minloglevel = 0; |
602 //FLAGS_v = 1; | 626 //FLAGS_v = 1; |
603 | 627 |
604 Toolbox::DetectEndianness(); | 628 Toolbox::DetectEndianness(); |
605 | 629 |
606 google::InitGoogleLogging("Orthanc"); | 630 google::InitGoogleLogging("Orthanc"); |
631 | |
632 Toolbox::CreateDirectory("UnitTestsResults"); | |
607 | 633 |
608 OrthancInitialize(); | 634 OrthancInitialize(); |
609 ::testing::InitGoogleTest(&argc, argv); | 635 ::testing::InitGoogleTest(&argc, argv); |
610 int result = RUN_ALL_TESTS(); | 636 int result = RUN_ALL_TESTS(); |
611 OrthancFinalize(); | 637 OrthancFinalize(); |