comparison UnitTests/main.cpp @ 624:b58d65608949

integration find-move-scp -> mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Oct 2013 12:42:38 +0200
parents 0bedf8ff9288
children
comparison
equal deleted inserted replaced
609:5651d2c6f6fd 624:b58d65608949
125 ASSERT_EQ(0x103E, t.GetElement()); 125 ASSERT_EQ(0x103E, t.GetElement());
126 126
127 t = FromDcmtkBridge::ParseTag("0020-e040"); 127 t = FromDcmtkBridge::ParseTag("0020-e040");
128 ASSERT_EQ(0x0020, t.GetGroup()); 128 ASSERT_EQ(0x0020, t.GetGroup());
129 ASSERT_EQ(0xe040, t.GetElement()); 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));
130 } 134 }
131 135
132 136
133 TEST(Uri, SplitUriComponents) 137 TEST(Uri, SplitUriComponents)
134 { 138 {
385 ASSERT_STREQ("CompletedSeries", EnumerationToString(ChangeType_CompletedSeries)); 389 ASSERT_STREQ("CompletedSeries", EnumerationToString(ChangeType_CompletedSeries));
386 390
387 ASSERT_EQ("IndexInSeries", EnumerationToString(MetadataType_Instance_IndexInSeries)); 391 ASSERT_EQ("IndexInSeries", EnumerationToString(MetadataType_Instance_IndexInSeries));
388 ASSERT_EQ("LastUpdate", EnumerationToString(MetadataType_LastUpdate)); 392 ASSERT_EQ("LastUpdate", EnumerationToString(MetadataType_LastUpdate));
389 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
390 ASSERT_EQ(2047, StringToMetadata("2047")); 401 ASSERT_EQ(2047, StringToMetadata("2047"));
391 ASSERT_THROW(StringToMetadata("Ceci est un test"), OrthancException); 402 ASSERT_THROW(StringToMetadata("Ceci est un test"), OrthancException);
392 ASSERT_THROW(RegisterUserMetadata(128, ""), OrthancException); // too low (< 1024) 403 ASSERT_THROW(RegisterUserMetadata(128, ""), OrthancException); // too low (< 1024)
393 ASSERT_THROW(RegisterUserMetadata(128000, ""), OrthancException); // too high (> 65535) 404 ASSERT_THROW(RegisterUserMetadata(128000, ""), OrthancException); // too high (> 65535)
394 RegisterUserMetadata(2047, "Ceci est un test"); 405 RegisterUserMetadata(2047, "Ceci est un test");
478 std::string u; 489 std::string u;
479 ASSERT_THROW(Toolbox::ReadFile(u, path.c_str()), OrthancException); 490 ASSERT_THROW(Toolbox::ReadFile(u, path.c_str()), OrthancException);
480 } 491 }
481 492
482 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
483 int main(int argc, char **argv) 525 int main(int argc, char **argv)
484 { 526 {
485 // Initialize Google's logging library. 527 // Initialize Google's logging library.
486 FLAGS_logtostderr = true; 528 FLAGS_logtostderr = true;
487 FLAGS_minloglevel = 0; 529 FLAGS_minloglevel = 0;