Mercurial > hg > orthanc
changeset 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 | a3b8924bd12a |
children | b88937ef597b |
files | UnitTestsSources/FromDcmtkTests.cpp |
diffstat | 1 files changed, 30 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/UnitTestsSources/FromDcmtkTests.cpp Mon Feb 25 19:57:33 2019 +0100 +++ b/UnitTestsSources/FromDcmtkTests.cpp Tue Feb 26 13:10:40 2019 +0100 @@ -1521,6 +1521,18 @@ +// Compatibility wrapper +static pugi::xpath_node SelectNode(const pugi::xml_document& doc, + const char* xpath) +{ +#if PUGIXML_VERSION <= 140 + return doc.select_single_node(xpath); // Deprecated in pugixml 1.5 +#else + return doc.select_node(xpath); +#endif +} + + TEST(Toolbox, EncodingsKorean) { // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_I.2.html @@ -1569,37 +1581,36 @@ pugi::xml_document doc; doc.load_buffer(xml.c_str(), xml.size()); - pugi::xpath_node node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value"); + pugi::xpath_node node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value"); ASSERT_STREQ("ISO_IR 192", node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]"); ASSERT_STREQ("CS", node.node().attribute("vr").value()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]"); ASSERT_STREQ("PN", node.node().attribute("vr").value()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName"); ASSERT_STREQ("Hong", node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName"); ASSERT_STREQ("Gildong", node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName"); ASSERT_EQ(utf8.substr(13, 3), node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName"); ASSERT_EQ(utf8.substr(17, 6), node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName"); ASSERT_EQ(utf8.substr(24, 3), node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName"); ASSERT_EQ(utf8.substr(28), node.node().text().as_string()); #endif } - TEST(Toolbox, EncodingsJapaneseKanji) { // http://dicom.nema.org/MEDICAL/dicom/current/output/chtml/part05/sect_H.3.html @@ -1650,31 +1661,31 @@ pugi::xml_document doc; doc.load_buffer(xml.c_str(), xml.size()); - pugi::xpath_node node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value"); + pugi::xpath_node node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]/Value"); ASSERT_STREQ("ISO_IR 192", node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00080005\"]"); ASSERT_STREQ("CS", node.node().attribute("vr").value()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]"); ASSERT_STREQ("PN", node.node().attribute("vr").value()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/FamilyName"); ASSERT_STREQ("Yamada", node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Alphabetic/GivenName"); ASSERT_STREQ("Tarou", node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/FamilyName"); ASSERT_EQ(utf8.substr(13, 6), node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Ideographic/GivenName"); ASSERT_EQ(utf8.substr(20, 6), node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/FamilyName"); ASSERT_EQ(utf8.substr(27, 9), node.node().text().as_string()); - node = doc.select_node("//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName"); + node = SelectNode(doc, "//NativeDicomModel/DicomAttribute[@tag=\"00100010\"]/PersonName/Phonetic/GivenName"); ASSERT_EQ(utf8.substr(37), node.node().text().as_string()); #endif }