Mercurial > hg > orthanc-databases
comparison Framework/Plugins/IndexUnitTests.h @ 335:7ec461718edb
unit test of metadata and tags in UTF8
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 11 Aug 2021 11:07:55 +0200 |
parents | eb0b04c10bc4 |
children | 16aac0287485 |
comparison
equal
deleted
inserted
replaced
334:75ff5ce4a995 | 335:7ec461718edb |
---|---|
64 MetadataType_LastUpdate | 64 MetadataType_LastUpdate |
65 }; | 65 }; |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 /** | |
70 * This is a sample UTF8 string that is the concatenation of a Korean | |
71 * and a Kanji text. Check out "utf8raw" in | |
72 * "OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp" for the | |
73 * sources of these binary values. | |
74 **/ | |
75 static const uint8_t UTF8[] = { | |
76 // cf. TEST(Toolbox, EncodingsKorean) | |
77 0x48, 0x6f, 0x6e, 0x67, 0x5e, 0x47, 0x69, 0x6c, 0x64, 0x6f, 0x6e, 0x67, 0x3d, 0xe6, | |
78 0xb4, 0xaa, 0x5e, 0xe5, 0x90, 0x89, 0xe6, 0xb4, 0x9e, 0x3d, 0xed, 0x99, 0x8d, 0x5e, | |
79 0xea, 0xb8, 0xb8, 0xeb, 0x8f, 0x99, | |
80 | |
81 // cf. TEST(Toolbox, EncodingsJapaneseKanji) | |
82 0x59, 0x61, 0x6d, 0x61, 0x64, 0x61, 0x5e, 0x54, 0x61, 0x72, 0x6f, 0x75, 0x3d, 0xe5, | |
83 0xb1, 0xb1, 0xe7, 0x94, 0xb0, 0x5e, 0xe5, 0xa4, 0xaa, 0xe9, 0x83, 0x8e, 0x3d, 0xe3, | |
84 0x82, 0x84, 0xe3, 0x81, 0xbe, 0xe3, 0x81, 0xa0, 0x5e, 0xe3, 0x81, 0x9f, 0xe3, 0x82, | |
85 0x8d, 0xe3, 0x81, 0x86, | |
86 | |
87 // End of text | |
88 0x00 | |
89 }; | |
90 | |
91 | |
69 static std::unique_ptr<OrthancPluginAttachment> expectedAttachment; | 92 static std::unique_ptr<OrthancPluginAttachment> expectedAttachment; |
70 static std::list<OrthancPluginDicomTag> expectedDicomTags; | 93 static std::list<OrthancPluginDicomTag> expectedDicomTags; |
71 static std::unique_ptr<OrthancPluginExportedResource> expectedExported; | 94 static std::unique_ptr<OrthancPluginExportedResource> expectedExported; |
72 | 95 |
73 static std::map<std::string, OrthancPluginResourceType> deletedResources; | 96 static std::map<std::string, OrthancPluginResourceType> deletedResources; |
74 static std::unique_ptr< std::pair<std::string, OrthancPluginResourceType> > remainingAncestor; | 97 static std::unique_ptr< std::pair<std::string, OrthancPluginResourceType> > remainingAncestor; |
75 static std::set<std::string> deletedAttachments; | 98 static std::set<std::string> deletedAttachments; |
99 static unsigned int countDicomTags = 0; | |
76 | 100 |
77 | 101 |
78 static void CheckAttachment(const OrthancPluginAttachment& attachment) | 102 static void CheckAttachment(const OrthancPluginAttachment& attachment) |
79 { | 103 { |
80 ASSERT_STREQ(expectedAttachment->uuid, attachment.uuid); | 104 ASSERT_STREQ(expectedAttachment->uuid, attachment.uuid); |
150 case _OrthancPluginDatabaseAnswerType_DicomTag: | 174 case _OrthancPluginDatabaseAnswerType_DicomTag: |
151 { | 175 { |
152 const OrthancPluginDicomTag& tag = | 176 const OrthancPluginDicomTag& tag = |
153 *reinterpret_cast<const OrthancPluginDicomTag*>(answer.valueGeneric); | 177 *reinterpret_cast<const OrthancPluginDicomTag*>(answer.valueGeneric); |
154 CheckDicomTag(tag); | 178 CheckDicomTag(tag); |
179 countDicomTags++; | |
155 break; | 180 break; |
156 } | 181 } |
157 | 182 |
158 case _OrthancPluginDatabaseAnswerType_DeletedResource: | 183 case _OrthancPluginDatabaseAnswerType_DeletedResource: |
159 deletedResources[answer.valueString] = static_cast<OrthancPluginResourceType>(answer.valueInt32); | 184 deletedResources[answer.valueString] = static_cast<OrthancPluginResourceType>(answer.valueInt32); |
323 ASSERT_EQ(43, revision); | 348 ASSERT_EQ(43, revision); |
324 #else | 349 #else |
325 ASSERT_EQ(0, revision); | 350 ASSERT_EQ(0, revision); |
326 #endif | 351 #endif |
327 | 352 |
328 db.SetMetadata(*manager, a, Orthanc::MetadataType_LastUpdate, "update", 44); | 353 db.SetMetadata(*manager, a, Orthanc::MetadataType_LastUpdate, reinterpret_cast<const char*>(UTF8), 44); |
329 ASSERT_TRUE(db.LookupMetadata(s, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); | 354 ASSERT_TRUE(db.LookupMetadata(s, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); |
330 ASSERT_EQ("update", s); | 355 ASSERT_STREQ(reinterpret_cast<const char*>(UTF8), s.c_str()); |
331 | 356 |
332 #if HAS_REVISIONS == 1 | 357 #if HAS_REVISIONS == 1 |
333 ASSERT_EQ(44, revision); | 358 ASSERT_EQ(44, revision); |
334 #else | 359 #else |
335 ASSERT_EQ(0, revision); | 360 ASSERT_EQ(0, revision); |
349 #else | 374 #else |
350 ASSERT_EQ(0, revision); | 375 ASSERT_EQ(0, revision); |
351 #endif | 376 #endif |
352 | 377 |
353 ASSERT_TRUE(db.LookupMetadata(mdd, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); | 378 ASSERT_TRUE(db.LookupMetadata(mdd, revision, *manager, a, Orthanc::MetadataType_LastUpdate)); |
354 ASSERT_EQ("update", mdd); | 379 ASSERT_EQ(reinterpret_cast<const char*>(UTF8), mdd); |
355 | 380 |
356 #if HAS_REVISIONS == 1 | 381 #if HAS_REVISIONS == 1 |
357 ASSERT_EQ(44, revision); | 382 ASSERT_EQ(44, revision); |
358 #else | 383 #else |
359 ASSERT_EQ(0, revision); | 384 ASSERT_EQ(0, revision); |
449 ASSERT_EQ(Orthanc::FileContentType_DicomAsJson, fc.front()); | 474 ASSERT_EQ(Orthanc::FileContentType_DicomAsJson, fc.front()); |
450 db.DeleteAttachment(*output, *manager, a, Orthanc::FileContentType_DicomAsJson); | 475 db.DeleteAttachment(*output, *manager, a, Orthanc::FileContentType_DicomAsJson); |
451 db.ListAvailableAttachments(fc, *manager, a); | 476 db.ListAvailableAttachments(fc, *manager, a); |
452 ASSERT_EQ(0u, fc.size()); | 477 ASSERT_EQ(0u, fc.size()); |
453 | 478 |
454 | |
455 db.SetIdentifierTag(*manager, a, 0x0010, 0x0020, "patient"); | 479 db.SetIdentifierTag(*manager, a, 0x0010, 0x0020, "patient"); |
456 db.SetIdentifierTag(*manager, a, 0x0020, 0x000d, "study"); | 480 db.SetIdentifierTag(*manager, a, 0x0020, 0x000d, "study"); |
481 db.SetMainDicomTag(*manager, a, 0x0010, 0x0020, "patient"); | |
482 db.SetMainDicomTag(*manager, a, 0x0020, 0x000d, "study"); | |
483 db.SetMainDicomTag(*manager, a, 0x0008, 0x1030, reinterpret_cast<const char*>(UTF8)); | |
457 | 484 |
458 expectedDicomTags.clear(); | 485 expectedDicomTags.clear(); |
459 expectedDicomTags.push_back(OrthancPluginDicomTag()); | 486 expectedDicomTags.push_back(OrthancPluginDicomTag()); |
487 expectedDicomTags.back().group = 0x0010; | |
488 expectedDicomTags.back().element = 0x0020; | |
489 expectedDicomTags.back().value = "patient"; | |
460 expectedDicomTags.push_back(OrthancPluginDicomTag()); | 490 expectedDicomTags.push_back(OrthancPluginDicomTag()); |
461 expectedDicomTags.front().group = 0x0010; | |
462 expectedDicomTags.front().element = 0x0020; | |
463 expectedDicomTags.front().value = "patient"; | |
464 expectedDicomTags.back().group = 0x0020; | 491 expectedDicomTags.back().group = 0x0020; |
465 expectedDicomTags.back().element = 0x000d; | 492 expectedDicomTags.back().element = 0x000d; |
466 expectedDicomTags.back().value = "study"; | 493 expectedDicomTags.back().value = "study"; |
494 expectedDicomTags.push_back(OrthancPluginDicomTag()); | |
495 expectedDicomTags.back().group = 0x0008; | |
496 expectedDicomTags.back().element = 0x1030; | |
497 expectedDicomTags.back().value = reinterpret_cast<const char*>(UTF8); | |
498 | |
499 countDicomTags = 0; | |
467 db.GetMainDicomTags(*output, *manager, a); | 500 db.GetMainDicomTags(*output, *manager, a); |
468 | 501 ASSERT_EQ(3u, countDicomTags); |
469 | 502 |
470 db.LookupIdentifier(ci, *manager, OrthancPluginResourceType_Study, 0x0010, 0x0020, | 503 db.LookupIdentifier(ci, *manager, OrthancPluginResourceType_Study, 0x0010, 0x0020, |
471 OrthancPluginIdentifierConstraint_Equal, "patient"); | 504 OrthancPluginIdentifierConstraint_Equal, "patient"); |
472 ASSERT_EQ(1u, ci.size()); | 505 ASSERT_EQ(1u, ci.size()); |
473 ASSERT_EQ(a, ci.front()); | 506 ASSERT_EQ(a, ci.front()); |