diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-05-01 09:17:14 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-05-01 12:30:22 +0200 |
commit | d822953cbc1d8814ac9f9eac2107177d37103542 (patch) | |
tree | bfe57eba2ec0e1dbb816d3ce5972298d65780b3d /test/qa | |
parent | 54fa7c42d4b0907a0aba820ce167b8929c0f0246 (diff) |
Make getXPathPosition assert on requested child found
Previously, for an XML like this:
<sharedItems>
<d v="2017-07-10T09:11:02"/>
<d v="2017-07-10T09:11:03"/>
<m/>
</sharedItems>
the call like
int pos = getXPathPosition(pDoc, "/x:sharedItems", "absent");
gave 3. That could result in mistakes, when a test would assert
on position "3" for a child element which name is mistyped.
I made such a mistake when creating a unit test trying to assert on
a position of the last element, and writing its name as "x:m", like
in rXPath itself; the return was 3, and I initially wrongly assumed
that the return is 1-based (like in xpath bracketed expressions).
rChildName made const OString&, for consistency with rXPath, or with
rAttribute in getXPath: child name is just a part of a longer xpath.
Change-Id: I7ba9c4466c75b1b10fce1ccf26ef3b56b4e11e87
Reviewed-on: https://gerrit.libreoffice.org/71614
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'test/qa')
-rw-r--r-- | test/qa/cppunit/test_xpath.cxx | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/test/qa/cppunit/test_xpath.cxx b/test/qa/cppunit/test_xpath.cxx index 83b48c84f488..a5693d1c9f76 100644 --- a/test/qa/cppunit/test_xpath.cxx +++ b/test/qa/cppunit/test_xpath.cxx @@ -33,6 +33,8 @@ CPPUNIT_TEST_FIXTURE(TestXPath, test_getXPath) CPPUNIT_ASSERT_EQUAL(OUString(), getXPath(pTable, "/xml/item", "")); // Must properly return attribute content 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")); } CPPUNIT_PLUGIN_IMPLEMENT(); |