test/qa/cppunit/test_xpath.cxx | 3 +++ test/source/xmltesttools.cxx | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
New commits: commit 798d19c80853166042ce8a14edf4a25cd491d6aa Author: Mike Kaganski <[email protected]> AuthorDate: Thu Jul 15 00:03:13 2021 +0200 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Jul 15 08:01:29 2021 +0200 Fix UB calling operator<<(std::basic_ostream) with nullptr This resulted in segfault instead of a useful test failure message. Was this way ever since 548b360c0e4693aac0cbdd2fcc1aab433fc54010, and before in 6e31cbb4eaea3c6600248ba59a22853acc1d6606 and 9791453283407a0a129a71767a290058ac759da2. Change-Id: I498d1c84a4eaf3e8180dedd67d1176cf6f8c1a60 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118916 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/test/qa/cppunit/test_xpath.cxx b/test/qa/cppunit/test_xpath.cxx index 12852fc7dc6e..87d6a7ac177e 100644 --- a/test/qa/cppunit/test_xpath.cxx +++ b/test/qa/cppunit/test_xpath.cxx @@ -35,6 +35,9 @@ CPPUNIT_TEST_FIXTURE(TestXPath, test_getXPath) CPPUNIT_ASSERT_EQUAL(OUString("val"), getXPath(pTable, "/xml/item", "attrib")); // Trying to get position of missing child of a node must fail assertion CPPUNIT_ASSERT_ASSERTION_FAIL(getXPathPosition(pTable, "/xml/item", "absent")); + // Asserting that an attribute is absent + CPPUNIT_ASSERT_ASSERTION_FAIL(assertXPathNoAttribute(pTable, "/xml/item", "attrib")); + CPPUNIT_ASSERT_ASSERTION_PASS(assertXPathNoAttribute(pTable, "/xml/item", "foo")); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index 12aed37f18e0..f92c380d9bf8 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -247,8 +247,8 @@ void XmlTestTools::assertXPathNoAttribute(const xmlDocUniquePtr& pXmlDoc, const CPPUNIT_ASSERT_EQUAL_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + rXPath + "' number of nodes is incorrect").getStr(), 1, xmlXPathNodeSetGetLength(pXmlNodes)); xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; - CPPUNIT_ASSERT_EQUAL_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + rXPath + "' unexpected '" + rAttribute + "' attribute").getStr(), - static_cast<xmlChar*>(nullptr), xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr()))); + CPPUNIT_ASSERT_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + rXPath + "' unexpected '" + rAttribute + "' attribute").getStr(), + !xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr()))); xmlXPathFreeObject(pXmlObj); } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
