From 548b360c0e4693aac0cbdd2fcc1aab433fc54010 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 30 Sep 2014 11:48:59 +0200 Subject: Factor out duplicated code to XmlTestTools::assertXPathNoAttribute() Change-Id: I1eb3778e6bcdd8c44ffb9a7548add109331fc83b --- test/source/xmltesttools.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/source') diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index 5ba9162dcac1..32908a068699 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -114,6 +114,18 @@ void XmlTestTools::assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath, #endif } +void XmlTestTools::assertXPathNoAttribute(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute) +{ + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, rXPath); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("In <" + OString(pXmlDoc->name) + ">, XPath '" + rXPath + "' number of nodes is incorrect").getStr(), + 1, xmlXPathNodeSetGetLength(pXmlNodes)); + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("In <" + OString(pXmlDoc->name) + ">, XPath '" + rXPath + "' unexpected '" + rAttribute + "' attribute").getStr(), + static_cast(0), xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr()))); + xmlXPathFreeObject(pXmlObj); +} + int XmlTestTools::getXPathPosition(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rChildName) { xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, rXPath); -- cgit v1.2.3