Mercurial > hg > orthanc
comparison UnitTestsSources/FromDcmtkTests.cpp @ 1736:b953c6eef28d
ToJson: IncludePrivateTags and IncludeUnknownTags
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 21 Oct 2015 16:52:23 +0200 |
parents | a001f6226c7c |
children | df331354cea2 |
comparison
equal
deleted
inserted
replaced
1735:a001f6226c7c | 1736:b953c6eef28d |
---|---|
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 TEST(ParsedDicomFile, ToJsonFlags) | 524 TEST(ParsedDicomFile, ToJsonFlags) |
525 { | 525 { |
526 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7053, 0x1000), EVR_PN, "MyPrivateTag", 1, 1); | |
527 FromDcmtkBridge::RegisterDictionaryTag(DicomTag(0x7050, 0x1000), EVR_PN, "Declared public tag", 1, 1); | |
528 | |
526 { | 529 { |
527 ParsedDicomFile f; | 530 ParsedDicomFile f; |
528 f.Insert(DicomTag(0x7053, 0x1000), "Some private tag", false); | 531 f.Insert(DicomTag(0x7050, 0x1000), "Some public tag", false); // Even group => public tag |
532 f.Insert(DicomTag(0x7052, 0x1000), "Some unknown tag", false); // Even group => public, unknown tag | |
533 f.Insert(DicomTag(0x7053, 0x1000), "Some private tag", false); // Odd group => private tag | |
529 | 534 |
530 Json::Value v; | 535 Json::Value v; |
531 f.ToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); | 536 f.ToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_None, 0); |
532 ASSERT_EQ(Json::objectValue, v.type()); | 537 ASSERT_EQ(Json::objectValue, v.type()); |
533 ASSERT_EQ(5, v.getMemberNames().size()); | 538 ASSERT_EQ(6, v.getMemberNames().size()); |
534 ASSERT_FALSE(v.isMember("7053-1000")); | 539 ASSERT_FALSE(v.isMember("7052,1000")); |
540 ASSERT_FALSE(v.isMember("7053,1000")); | |
541 ASSERT_TRUE(v.isMember("7050,1000")); | |
542 ASSERT_EQ(Json::stringValue, v["7050,1000"].type()); | |
543 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); | |
535 | 544 |
536 f.ToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePrivateTags, 0); | 545 f.ToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludePrivateTags, 0); |
537 ASSERT_EQ(Json::objectValue, v.type()); | 546 ASSERT_EQ(Json::objectValue, v.type()); |
538 ASSERT_EQ(6, v.getMemberNames().size()); | 547 ASSERT_EQ(7, v.getMemberNames().size()); |
548 ASSERT_FALSE(v.isMember("7052,1000")); | |
549 ASSERT_TRUE(v.isMember("7050,1000")); | |
539 ASSERT_TRUE(v.isMember("7053,1000")); | 550 ASSERT_TRUE(v.isMember("7053,1000")); |
540 ASSERT_EQ(Json::nullValue, v["7053,1000"].type()); | 551 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); |
541 } | 552 ASSERT_EQ(Json::nullValue, v["7053,1000"].type()); // TODO SHOULD BE STRING |
542 } | 553 |
554 f.ToJson(v, DicomToJsonFormat_Short, DicomToJsonFlags_IncludeUnknownTags, 0); | |
555 ASSERT_EQ(Json::objectValue, v.type()); | |
556 ASSERT_EQ(7, v.getMemberNames().size()); | |
557 ASSERT_TRUE(v.isMember("7050,1000")); | |
558 ASSERT_TRUE(v.isMember("7052,1000")); | |
559 ASSERT_FALSE(v.isMember("7053,1000")); | |
560 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); | |
561 ASSERT_EQ(Json::nullValue, v["7052,1000"].type()); // TODO SHOULD BE STRING | |
562 | |
563 f.ToJson(v, DicomToJsonFormat_Short, static_cast<DicomToJsonFlags>(DicomToJsonFlags_IncludeUnknownTags | DicomToJsonFlags_IncludePrivateTags), 0); | |
564 ASSERT_EQ(Json::objectValue, v.type()); | |
565 ASSERT_EQ(8, v.getMemberNames().size()); | |
566 ASSERT_TRUE(v.isMember("7050,1000")); | |
567 ASSERT_TRUE(v.isMember("7052,1000")); | |
568 ASSERT_TRUE(v.isMember("7053,1000")); | |
569 ASSERT_EQ("Some public tag", v["7050,1000"].asString()); | |
570 ASSERT_EQ(Json::nullValue, v["7052,1000"].type()); // TODO SHOULD BE STRING | |
571 ASSERT_EQ(Json::nullValue, v["7053,1000"].type()); // TODO SHOULD BE STRING | |
572 } | |
573 } |