Mercurial > hg > orthanc
comparison UnitTestsSources/FromDcmtkTests.cpp @ 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 |
comparison
equal
deleted
inserted
replaced
3224:6399f5f25498 | 3225:c85510b5f21d |
---|---|
1542 ParsedDicomFile dicom(false); | 1542 ParsedDicomFile dicom(false); |
1543 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 149"); | 1543 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 149"); |
1544 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString | 1544 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
1545 (DCM_PatientName, korean.c_str(), korean.size(), true).good()); | 1545 (DCM_PatientName, korean.c_str(), korean.size(), true).good()); |
1546 | 1546 |
1547 bool hasCodeExtensions; | |
1548 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); | |
1549 ASSERT_EQ(Encoding_Korean, encoding); | |
1550 ASSERT_TRUE(hasCodeExtensions); | |
1551 | |
1547 std::string value; | 1552 std::string value; |
1548 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); | 1553 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
1549 ASSERT_EQ(utf8, value); | 1554 ASSERT_EQ(utf8, value); |
1550 | 1555 |
1551 DicomWebJsonVisitor visitor; | 1556 DicomWebJsonVisitor visitor; |
1591 #endif | 1596 #endif |
1592 } | 1597 } |
1593 | 1598 |
1594 | 1599 |
1595 | 1600 |
1596 TEST(Toolbox, EncodingsJapanese) | 1601 TEST(Toolbox, EncodingsJapaneseKanji) |
1597 { | 1602 { |
1598 // http://dicom.nema.org/MEDICAL/dicom/2017c/output/chtml/part05/sect_H.3.html | 1603 // http://dicom.nema.org/MEDICAL/dicom/2017c/output/chtml/part05/sect_H.3.html |
1599 | 1604 |
1600 std::string japanese = DecodeFromSpecification( | 1605 std::string japanese = DecodeFromSpecification( |
1601 "05/09 06/01 06/13 06/01 06/04 06/01 05/14 05/04 06/01 07/02 06/15 07/05 03/13 " | 1606 "05/09 06/01 06/13 06/01 06/04 06/01 05/14 05/04 06/01 07/02 06/15 07/05 03/13 " |
1617 | 1622 |
1618 ParsedDicomFile dicom(false); | 1623 ParsedDicomFile dicom(false); |
1619 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 87"); | 1624 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "\\ISO 2022 IR 87"); |
1620 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString | 1625 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
1621 (DCM_PatientName, japanese.c_str(), japanese.size(), true).good()); | 1626 (DCM_PatientName, japanese.c_str(), japanese.size(), true).good()); |
1627 | |
1628 bool hasCodeExtensions; | |
1629 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); | |
1630 ASSERT_EQ(Encoding_JapaneseKanji, encoding); | |
1631 ASSERT_TRUE(hasCodeExtensions); | |
1622 | 1632 |
1623 std::string value; | 1633 std::string value; |
1624 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); | 1634 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
1625 ASSERT_EQ(utf8, value); | 1635 ASSERT_EQ(utf8, value); |
1626 | 1636 |
1681 ParsedDicomFile dicom(false); | 1691 ParsedDicomFile dicom(false); |
1682 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); | 1692 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); |
1683 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString | 1693 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
1684 (DCM_PatientName, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good()); | 1694 (DCM_PatientName, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good()); |
1685 | 1695 |
1696 bool hasCodeExtensions; | |
1697 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); | |
1698 ASSERT_EQ(Encoding_Chinese, encoding); | |
1699 ASSERT_FALSE(hasCodeExtensions); | |
1700 | |
1686 std::string value; | 1701 std::string value; |
1687 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); | 1702 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_NAME)); |
1688 | 1703 |
1689 std::vector<std::string> tokens; | 1704 std::vector<std::string> tokens; |
1690 Orthanc::Toolbox::TokenizeString(tokens, value, '='); | 1705 Orthanc::Toolbox::TokenizeString(tokens, value, '='); |
1737 | 1752 |
1738 ParsedDicomFile dicom(false); | 1753 ParsedDicomFile dicom(false); |
1739 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); | 1754 dicom.ReplacePlainString(DICOM_TAG_SPECIFIC_CHARACTER_SET, "GB18030"); |
1740 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString | 1755 ASSERT_TRUE(dicom.GetDcmtkObject().getDataset()->putAndInsertString |
1741 (DCM_PatientComments, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good()); | 1756 (DCM_PatientComments, reinterpret_cast<const char*>(chinese), sizeof(chinese), true).good()); |
1757 | |
1758 bool hasCodeExtensions; | |
1759 Encoding encoding = dicom.DetectEncoding(hasCodeExtensions); | |
1760 ASSERT_EQ(Encoding_Chinese, encoding); | |
1761 ASSERT_FALSE(hasCodeExtensions); | |
1742 | 1762 |
1743 std::string value; | 1763 std::string value; |
1744 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_COMMENTS)); | 1764 ASSERT_TRUE(dicom.GetTagValue(value, DICOM_TAG_PATIENT_COMMENTS)); |
1745 | 1765 |
1746 std::vector<std::string> lines; | 1766 std::vector<std::string> lines; |