comparison UnitTestsSources/FromDcmtkTests.cpp @ 3228:4b9cfd92d1ae

preparing for libicu
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 14 Feb 2019 19:41:09 +0100
parents 45e1631febbb
children 77e8378f0323
comparison
equal deleted inserted replaced
3227:53bb1f4b3844 3228:4b9cfd92d1ae
1505 } 1505 }
1506 1506
1507 int a = boost::lexical_cast<int>(components[0]); 1507 int a = boost::lexical_cast<int>(components[0]);
1508 int b = boost::lexical_cast<int>(components[1]); 1508 int b = boost::lexical_cast<int>(components[1]);
1509 if (a < 0 || a > 15 || 1509 if (a < 0 || a > 15 ||
1510 b < 0 || b > 15) 1510 b < 0 || b > 15 ||
1511 (a == 0 && b == 0))
1511 { 1512 {
1512 throw; 1513 throw;
1513 } 1514 }
1514 1515
1515 result[i] = static_cast<uint8_t>(a * 16 + b); 1516 result[i] = static_cast<uint8_t>(a * 16 + b);
1541 std::string utf8(reinterpret_cast<const char*>(utf8raw), sizeof(utf8raw)); 1542 std::string utf8(reinterpret_cast<const char*>(utf8raw), sizeof(utf8raw));
1542 1543
1543 ParsedDicomFile dicom(false); 1544 ParsedDicomFile dicom(false);
1544 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 149"); 1545 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 149");
1545 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString 1546 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
1546 (DCM_PatientName, korean.c_str(), korean.size(), true).good()); 1547 (DCM_PatientName, korean.c_str(), OFBool(true)).good());
1547 1548
1548 bool hasCodeExtensions; 1549 bool hasCodeExtensions;
1549 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); 1550 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
1550 ASSERT_EQ(Encoding_Korean, encoding); 1551 ASSERT_EQ(Encoding_Korean, encoding);
1551 ASSERT_TRUE(hasCodeExtensions); 1552 ASSERT_TRUE(hasCodeExtensions);
1622 std::string utf8(reinterpret_cast<const char*>(utf8raw), sizeof(utf8raw)); 1623 std::string utf8(reinterpret_cast<const char*>(utf8raw), sizeof(utf8raw));
1623 1624
1624 ParsedDicomFile dicom(false); 1625 ParsedDicomFile dicom(false);
1625 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 87"); 1626 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 87");
1626 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString 1627 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
1627 (DCM_PatientName, japanese.c_str(), japanese.size(), true).good()); 1628 (DCM_PatientName, japanese.c_str(), OFBool(true)).good());
1628 1629
1629 bool hasCodeExtensions; 1630 bool hasCodeExtensions;
1630 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); 1631 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
1631 ASSERT_EQ(Encoding_JapaneseKanji, encoding); 1632 ASSERT_EQ(Encoding_JapaneseKanji, encoding);
1632 ASSERT_TRUE(hasCodeExtensions); 1633 ASSERT_TRUE(hasCodeExtensions);
1690 }; 1691 };
1691 1692
1692 ParsedDicomFile dicom(false); 1693 ParsedDicomFile dicom(false);
1693 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); 1694 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030");
1694 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString 1695 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
1695 (DCM_PatientName, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good()); 1696 (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
1696 1697
1697 bool hasCodeExtensions; 1698 bool hasCodeExtensions;
1698 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); 1699 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
1699 ASSERT_EQ(Encoding_Chinese, encoding); 1700 ASSERT_EQ(Encoding_Chinese, encoding);
1700 ASSERT_FALSE(hasCodeExtensions); 1701 ASSERT_FALSE(hasCodeExtensions);
1752 const std::string pattern(reinterpret_cast<const char*>(patternRaw), sizeof(patternRaw)); 1753 const std::string pattern(reinterpret_cast<const char*>(patternRaw), sizeof(patternRaw));
1753 1754
1754 ParsedDicomFile dicom(false); 1755 ParsedDicomFile dicom(false);
1755 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); 1756 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030");
1756 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString 1757 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
1757 (DCM_PatientComments, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good()); 1758 (DCM_PatientComments, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
1758 1759
1759 bool hasCodeExtensions; 1760 bool hasCodeExtensions;
1760 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); 1761 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
1761 ASSERT_EQ(Encoding_Chinese, encoding); 1762 ASSERT_EQ(Encoding_Chinese, encoding);
1762 ASSERT_FALSE(hasCodeExtensions); 1763 ASSERT_FALSE(hasCodeExtensions);
1796 }; 1797 };
1797 1798
1798 ParsedDicomFile dicom(false); 1799 ParsedDicomFile dicom(false);
1799 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58"); 1800 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58");
1800 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString 1801 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
1801 (DCM_PatientName, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good()); 1802 (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
1802 1803
1803 bool hasCodeExtensions; 1804 bool hasCodeExtensions;
1804 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); 1805 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
1805 ASSERT_EQ(Encoding_SimplifiedChinese, encoding); 1806 ASSERT_EQ(Encoding_SimplifiedChinese, encoding);
1806 ASSERT_TRUE(hasCodeExtensions); 1807 ASSERT_TRUE(hasCodeExtensions);
1837 }; 1838 };
1838 1839
1839 ParsedDicomFile dicom(false); 1840 ParsedDicomFile dicom(false);
1840 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58"); 1841 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 58");
1841 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString 1842 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString
1842 (DCM_PatientName, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good()); 1843 (DCM_PatientName, reinterpret_cast<const char*>(chinese), OFBool(true)).good());
1843 1844
1844 bool hasCodeExtensions; 1845 bool hasCodeExtensions;
1845 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); 1846 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions);
1846 ASSERT_EQ(Encoding_SimplifiedChinese, encoding); 1847 ASSERT_EQ(Encoding_SimplifiedChinese, encoding);
1847 ASSERT_TRUE(hasCodeExtensions); 1848 ASSERT_TRUE(hasCodeExtensions);