diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-07-15 00:03:13 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-07-15 08:01:29 +0200 |
commit | 798d19c80853166042ce8a14edf4a25cd491d6aa (patch) | |
tree | 88ecc324115c0a1c8672b67dac8bbb7011c9dbe7 /test | |
parent | 717dc8e3575a18e1e18dc446031e6db4e60a873d (diff) |
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 <mike.kaganski@collabora.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/qa/cppunit/test_xpath.cxx | 3 | ||||
-rw-r--r-- | test/source/xmltesttools.cxx | 4 |
2 files changed, 5 insertions, 2 deletions
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); } |