tdf#120797: Apply transformation also to the extents of damage
[LibreOffice.git] / test / qa / cppunit / test_xpath.cxx
blob83b48c84f488807bccfb97dd280b85c95bc9081f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sal/types.h>
11 #include <test/xmltesttools.hxx>
12 #include <unotest/bootstrapfixturebase.hxx>
14 class TestXPath : public CppUnit::TestFixture, public XmlTestTools
18 CPPUNIT_TEST_FIXTURE(TestXPath, test_getXPath)
20 const xmlChar s_xml[] = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>"
21 "<xml><item attrib='val'>text</item></xml>";
22 xmlDocPtr pTable = xmlParseDoc(s_xml);
23 CPPUNIT_ASSERT(pTable);
24 // Must get existing element content without errors
25 CPPUNIT_ASSERT_ASSERTION_PASS(getXPath(pTable, "/xml/item", ""));
26 // Must error out when getting non-existing element
27 CPPUNIT_ASSERT_ASSERTION_FAIL(getXPath(pTable, "/xml/no_item", ""));
28 // Must get existing attribute value correctly
29 CPPUNIT_ASSERT_ASSERTION_PASS(getXPath(pTable, "/xml/item", "attrib"));
30 // Must fail when requested non-empty attribute doesn't exist
31 CPPUNIT_ASSERT_ASSERTION_FAIL(getXPath(pTable, "/xml/item", "no_attrib"));
32 // Must return empty string if not asking an attribute, regardless what is its content
33 CPPUNIT_ASSERT_EQUAL(OUString(), getXPath(pTable, "/xml/item", ""));
34 // Must properly return attribute content
35 CPPUNIT_ASSERT_EQUAL(OUString("val"), getXPath(pTable, "/xml/item", "attrib"));
38 CPPUNIT_PLUGIN_IMPLEMENT();
40 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */