changeset 3225:c85510b5f21d

unit testing ParsedDicomFile::DetectEncoding()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 14 Feb 2019 14:56:31 +0100
parents 6399f5f25498
children 45e1631febbb
files UnitTestsSources/FromDcmtkTests.cpp
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/UnitTestsSources/FromDcmtkTests.cpp	Thu Feb 14 14:48:43 2019 +0100
+++ b/UnitTestsSources/FromDcmtkTests.cpp	Thu Feb 14 14:56:31 2019 +0100
@@ -1544,6 +1544,11 @@
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
               (DCM_PatientName, korean.c_str(), korean.size(), true).good());
 
+  bool hasCodeExtensions;
+  Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
+  ASSERT_EQ(Encoding_Korean, encoding);
+  ASSERT_TRUE(hasCodeExtensions);
+  
   std::string value;
   ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME));
   ASSERT_EQ(utf8, value);
@@ -1593,7 +1598,7 @@
 
 
 
-TEST(Toolbox, EncodingsJapanese)
+TEST(Toolbox, EncodingsJapaneseKanji)
 {
   // http://dicom.nema.org/MEDICAL/dicom/2017c/output/chtml/part05/sect_H.3.html
 
@@ -1620,6 +1625,11 @@
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
               (DCM_PatientName, japanese.c_str(), japanese.size(), true).good());
 
+  bool hasCodeExtensions;
+  Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
+  ASSERT_EQ(Encoding_JapaneseKanji, encoding);
+  ASSERT_TRUE(hasCodeExtensions);
+
   std::string value;
   ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME));
   ASSERT_EQ(utf8, value);
@@ -1683,6 +1693,11 @@
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
               (DCM_PatientName, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good());
 
+  bool hasCodeExtensions;
+  Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
+  ASSERT_EQ(Encoding_Chinese, encoding);
+  ASSERT_FALSE(hasCodeExtensions);
+
   std::string value;
   ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME));
 
@@ -1740,6 +1755,11 @@
   ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
               (DCM_PatientComments, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good());
 
+  bool hasCodeExtensions;
+  Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
+  ASSERT_EQ(Encoding_Chinese, encoding);
+  ASSERT_FALSE(hasCodeExtensions);
+
   std::string value;
   ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_COMMENTS));