comparison UnitTestsSources/FromDcmtkTests.cpp @ 3311:f2f8aa6f78aa

compatibility with pugixml <= 1.4.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 26 Feb 2019 13:10:40 +0100
parents 8711cd9b47c5
children 63f59ad9381a
comparison
equal deleted inserted replaced
3310:a3b8924bd12a 3311:f2f8aa6f78aa
1519 return result; 1519 return result;
1520 } 1520 }
1521 1521
1522 1522
1523 1523
1524 // Compatibility wrapper
1525 static pugi::xpath_node SelectNode(const pugi::xml_document& doc,
1526 const char* xpath)
1527 {
1528 #if PUGIXML_VERSION <= 140
1529 return doc.select_single_node(xpath); // Deprecated in pugixml 1.5
1530 #else
1531 return doc.select_node(xpath);
1532 #endif
1533 }
1534
1535
1524 TEST(Toolbox, EncodingsKorean) 1536 TEST(Toolbox, EncodingsKorean)
1525 { 1537 {
1526 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_I.2.html 1538 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_I.2.html
1527 1539
1528 std::string korean = DecodeFromSpecification( 1540 std::string korean = DecodeFromSpecification(
1567 visitor.FormatXml(xml); 1579 visitor.FormatXml(xml);
1568 1580
1569 pugi::xml_document doc; 1581 pugi::xml_document doc;
1570 doc.load_buffer(xml.c_str(), xml.size()); 1582 doc.load_buffer(xml.c_str(), xml.size());
1571 1583
1572 pugi::xpath_node node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value"); 1584 pugi::xpath_node node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value");
1573 ASSERT_STREQ("ISO_IR 192", node.node().text().as_string()); 1585 ASSERT_STREQ("ISO_IR 192", node.node().text().as_string());
1574 1586
1575 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]"); 1587 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]");
1576 ASSERT_STREQ("CS", node.node().attribute("vr").value()); 1588 ASSERT_STREQ("CS", node.node().attribute("vr").value());
1577 1589
1578 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]"); 1590 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]");
1579 ASSERT_STREQ("PN", node.node().attribute("vr").value()); 1591 ASSERT_STREQ("PN", node.node().attribute("vr").value());
1580 1592
1581 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName"); 1593 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName");
1582 ASSERT_STREQ("Hong", node.node().text().as_string()); 1594 ASSERT_STREQ("Hong", node.node().text().as_string());
1583 1595
1584 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName"); 1596 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName");
1585 ASSERT_STREQ("Gildong", node.node().text().as_string()); 1597 ASSERT_STREQ("Gildong", node.node().text().as_string());
1586 1598
1587 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName"); 1599 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName");
1588 ASSERT_EQ(utf8.substr(13, 3), node.node().text().as_string()); 1600 ASSERT_EQ(utf8.substr(13, 3), node.node().text().as_string());
1589 1601
1590 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName"); 1602 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName");
1591 ASSERT_EQ(utf8.substr(17, 6), node.node().text().as_string()); 1603 ASSERT_EQ(utf8.substr(17, 6), node.node().text().as_string());
1592 1604
1593 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName"); 1605 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName");
1594 ASSERT_EQ(utf8.substr(24, 3), node.node().text().as_string()); 1606 ASSERT_EQ(utf8.substr(24, 3), node.node().text().as_string());
1595 1607
1596 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName"); 1608 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName");
1597 ASSERT_EQ(utf8.substr(28), node.node().text().as_string()); 1609 ASSERT_EQ(utf8.substr(28), node.node().text().as_string());
1598 #endif 1610 #endif
1599 } 1611 }
1600
1601 1612
1602 1613
1603 TEST(Toolbox, EncodingsJapaneseKanji) 1614 TEST(Toolbox, EncodingsJapaneseKanji)
1604 { 1615 {
1605 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_H.3.html 1616 // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_H.3.html
1648 visitor.FormatXml(xml); 1659 visitor.FormatXml(xml);
1649 1660
1650 pugi::xml_document doc; 1661 pugi::xml_document doc;
1651 doc.load_buffer(xml.c_str(), xml.size()); 1662 doc.load_buffer(xml.c_str(), xml.size());
1652 1663
1653 pugi::xpath_node node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value"); 1664 pugi::xpath_node node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value");
1654 ASSERT_STREQ("ISO_IR 192", node.node().text().as_string()); 1665 ASSERT_STREQ("ISO_IR 192", node.node().text().as_string());
1655 1666
1656 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]"); 1667 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]");
1657 ASSERT_STREQ("CS", node.node().attribute("vr").value()); 1668 ASSERT_STREQ("CS", node.node().attribute("vr").value());
1658 1669
1659 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]"); 1670 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]");
1660 ASSERT_STREQ("PN", node.node().attribute("vr").value()); 1671 ASSERT_STREQ("PN", node.node().attribute("vr").value());
1661 1672
1662 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName"); 1673 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName");
1663 ASSERT_STREQ("Yamada", node.node().text().as_string()); 1674 ASSERT_STREQ("Yamada", node.node().text().as_string());
1664 1675
1665 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName"); 1676 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName");
1666 ASSERT_STREQ("Tarou", node.node().text().as_string()); 1677 ASSERT_STREQ("Tarou", node.node().text().as_string());
1667 1678
1668 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName"); 1679 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName");
1669 ASSERT_EQ(utf8.substr(13, 6), node.node().text().as_string()); 1680 ASSERT_EQ(utf8.substr(13, 6), node.node().text().as_string());
1670 1681
1671 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName"); 1682 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName");
1672 ASSERT_EQ(utf8.substr(20, 6), node.node().text().as_string()); 1683 ASSERT_EQ(utf8.substr(20, 6), node.node().text().as_string());
1673 1684
1674 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName"); 1685 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName");
1675 ASSERT_EQ(utf8.substr(27, 9), node.node().text().as_string()); 1686 ASSERT_EQ(utf8.substr(27, 9), node.node().text().as_string());
1676 1687
1677 node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName"); 1688 node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName");
1678 ASSERT_EQ(utf8.substr(37), node.node().text().as_string()); 1689 ASSERT_EQ(utf8.substr(37), node.node().text().as_string());
1679 #endif 1690 #endif
1680 } 1691 }
1681 1692
1682 1693