changeset 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 75ff5ce4a995
children c0c12b3974b2
files Framework/Plugins/IndexUnitTests.h MySQL/UnitTests/UnitTestsMain.cpp PostgreSQL/UnitTests/UnitTestsMain.cpp SQLite/UnitTests/UnitTestsMain.cpp
diffstat 4 files changed, 44 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/IndexUnitTests.h	Wed Aug 11 08:28:43 2021 +0200
+++ b/Framework/Plugins/IndexUnitTests.h	Wed Aug 11 11:07:55 2021 +0200
@@ -66,6 +66,29 @@
 }
 
 
+/**
+ * This is a sample UTF8 string that is the concatenation of a Korean
+ * and a Kanji text. Check out "utf8raw" in
+ * "OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp" for the
+ * sources of these binary values.
+ **/
+static const uint8_t UTF8[] = {
+  // cf. TEST(Toolbox, EncodingsKorean)
+  0x48, 0x6f, 0x6e, 0x67, 0x5e, 0x47, 0x69, 0x6c, 0x64, 0x6f, 0x6e, 0x67, 0x3d, 0xe6,
+  0xb4, 0xaa, 0x5e, 0xe5, 0x90, 0x89, 0xe6, 0xb4, 0x9e, 0x3d, 0xed, 0x99, 0x8d, 0x5e,
+  0xea, 0xb8, 0xb8, 0xeb, 0x8f, 0x99,
+  
+  // cf. TEST(Toolbox, EncodingsJapaneseKanji)
+  0x59, 0x61, 0x6d, 0x61, 0x64, 0x61, 0x5e, 0x54, 0x61, 0x72, 0x6f, 0x75, 0x3d, 0xe5,
+  0xb1, 0xb1, 0xe7, 0x94, 0xb0, 0x5e, 0xe5, 0xa4, 0xaa, 0xe9, 0x83, 0x8e, 0x3d, 0xe3,
+  0x82, 0x84, 0xe3, 0x81, 0xbe, 0xe3, 0x81, 0xa0, 0x5e, 0xe3, 0x81, 0x9f, 0xe3, 0x82,
+  0x8d, 0xe3, 0x81, 0x86,
+
+  // End of text
+  0x00
+};
+
+
 static std::unique_ptr<OrthancPluginAttachment>  expectedAttachment;
 static std::list<OrthancPluginDicomTag>  expectedDicomTags;
 static std::unique_ptr<OrthancPluginExportedResource>  expectedExported;
@@ -73,6 +96,7 @@
 static std::map<std::string, OrthancPluginResourceType> deletedResources;
 static std::unique_ptr< std::pair<std::string, OrthancPluginResourceType> > remainingAncestor;
 static std::set<std::string> deletedAttachments;
+static unsigned int countDicomTags = 0;
 
 
 static void CheckAttachment(const OrthancPluginAttachment& attachment)
@@ -152,6 +176,7 @@
           const OrthancPluginDicomTag& tag = 
             *reinterpret_cast<const OrthancPluginDicomTag*>(answer.valueGeneric);
           CheckDicomTag(tag);
+          countDicomTags++;
           break;
         }
 
@@ -325,9 +350,9 @@
   ASSERT_EQ(0, revision);
 #endif
 
-  db.SetMetadata(*manager, a, Orthanc::MetadataType_LastUpdate, "update", 44);
+  db.SetMetadata(*manager, a, Orthanc::MetadataType_LastUpdate, reinterpret_cast<const char*>(UTF8), 44);
   ASSERT_TRUE(db.LookupMetadata(s, revision, *manager, a, Orthanc::MetadataType_LastUpdate));
-  ASSERT_EQ("update", s);
+  ASSERT_STREQ(reinterpret_cast<const char*>(UTF8), s.c_str());
 
 #if HAS_REVISIONS == 1
   ASSERT_EQ(44, revision);
@@ -351,7 +376,7 @@
 #endif
 
   ASSERT_TRUE(db.LookupMetadata(mdd, revision, *manager, a, Orthanc::MetadataType_LastUpdate));
-  ASSERT_EQ("update", mdd);
+  ASSERT_EQ(reinterpret_cast<const char*>(UTF8), mdd);
 
 #if HAS_REVISIONS == 1
   ASSERT_EQ(44, revision);
@@ -451,21 +476,29 @@
   db.ListAvailableAttachments(fc, *manager, a);
   ASSERT_EQ(0u, fc.size());
 
-
   db.SetIdentifierTag(*manager, a, 0x0010, 0x0020, "patient");
   db.SetIdentifierTag(*manager, a, 0x0020, 0x000d, "study");
+  db.SetMainDicomTag(*manager, a, 0x0010, 0x0020, "patient");
+  db.SetMainDicomTag(*manager, a, 0x0020, 0x000d, "study");
+  db.SetMainDicomTag(*manager, a, 0x0008, 0x1030, reinterpret_cast<const char*>(UTF8));
 
   expectedDicomTags.clear();
   expectedDicomTags.push_back(OrthancPluginDicomTag());
+  expectedDicomTags.back().group = 0x0010;
+  expectedDicomTags.back().element = 0x0020;
+  expectedDicomTags.back().value = "patient";
   expectedDicomTags.push_back(OrthancPluginDicomTag());
-  expectedDicomTags.front().group = 0x0010;
-  expectedDicomTags.front().element = 0x0020;
-  expectedDicomTags.front().value = "patient";
   expectedDicomTags.back().group = 0x0020;
   expectedDicomTags.back().element = 0x000d;
   expectedDicomTags.back().value = "study";
+  expectedDicomTags.push_back(OrthancPluginDicomTag());
+  expectedDicomTags.back().group = 0x0008;
+  expectedDicomTags.back().element = 0x1030;
+  expectedDicomTags.back().value = reinterpret_cast<const char*>(UTF8);
+
+  countDicomTags = 0;
   db.GetMainDicomTags(*output, *manager, a);
-
+  ASSERT_EQ(3u, countDicomTags);
 
   db.LookupIdentifier(ci, *manager, OrthancPluginResourceType_Study, 0x0010, 0x0020, 
                       OrthancPluginIdentifierConstraint_Equal, "patient");
--- a/MySQL/UnitTests/UnitTestsMain.cpp	Wed Aug 11 08:28:43 2021 +0200
+++ b/MySQL/UnitTests/UnitTestsMain.cpp	Wed Aug 11 11:07:55 2021 +0200
@@ -369,7 +369,7 @@
   ::testing::InitGoogleTest(&argc, argv);
   Orthanc::Logging::Initialize();
   Orthanc::Logging::EnableInfoLevel(true);
-  Orthanc::Logging::EnableTraceLevel(true);
+  // Orthanc::Logging::EnableTraceLevel(true);
   Orthanc::Toolbox::InitializeOpenSsl();
   Orthanc::HttpClient::GlobalInitialize();
   
--- a/PostgreSQL/UnitTests/UnitTestsMain.cpp	Wed Aug 11 08:28:43 2021 +0200
+++ b/PostgreSQL/UnitTests/UnitTestsMain.cpp	Wed Aug 11 11:07:55 2021 +0200
@@ -130,7 +130,7 @@
   Orthanc::Toolbox::InitializeOpenSsl();
   Orthanc::Logging::Initialize();
   Orthanc::Logging::EnableInfoLevel(true);
-  Orthanc::Logging::EnableTraceLevel(true);
+  //Orthanc::Logging::EnableTraceLevel(true);
 
   int result = RUN_ALL_TESTS();
 
--- a/SQLite/UnitTests/UnitTestsMain.cpp	Wed Aug 11 08:28:43 2021 +0200
+++ b/SQLite/UnitTests/UnitTestsMain.cpp	Wed Aug 11 11:07:55 2021 +0200
@@ -111,7 +111,7 @@
   ::testing::InitGoogleTest(&argc, argv);
   Orthanc::Logging::Initialize();
   Orthanc::Logging::EnableInfoLevel(true);
-  Orthanc::Logging::EnableTraceLevel(true);
+  // Orthanc::Logging::EnableTraceLevel(true);
 
   int result = RUN_ALL_TESTS();