diff --git a/tests/XPath/text_node_test.hpp b/tests/XPath/text_node_test.hpp index 8d2b62d9..690c8525 100755 --- a/tests/XPath/text_node_test.hpp +++ b/tests/XPath/text_node_test.hpp @@ -188,8 +188,62 @@ public: assertEquals(2, nodes.asNodeSet().size()); } // testFollowing3 - // FOLLOWING_SIBLING - // FOLLOWING + void testPreceding1() + { + extraSetUp(); + XPathValue_t nodes = parser_.evaluate(SA::construct_from_utf8("/root/node()[last()]/preceding::node()"), document_); + assertEquals(4, nodes.asNodeSet().size()); + } // testPreceding1 + + void testPreceding2() + { + extraSetUp(); + XPathValue_t nodes = parser_.evaluate(SA::construct_from_utf8("/root/node()[last()]/preceding::text()"), document_); + assertEquals(2, nodes.asNodeSet().size()); + } // testPreceding2 + + void testPreceding3() + { + extraSetUp(); + XPathValue_t node = parser_.evaluate(SA::construct_from_utf8("/root/node()[last()]/preceding::text()[1]"), document_); + assertEquals("fourfive", node.asString()); + } // testPreceding3 + + void testPreceding4() + { + extraSetUp(); + XPathValue_t node = parser_.evaluate(SA::construct_from_utf8("/root/node()[last()]/preceding::text()[2]"), document_); + assertEquals("onetwothree", node.asString()); + } // testPreceding4 + + void testPrecedingSibling1() + { + extraSetUp(); + XPathValue_t nodes = parser_.evaluate(SA::construct_from_utf8("/root/node()[last()]/preceding-sibling::node()"), document_); + assertEquals(4, nodes.asNodeSet().size()); + } // testPrecedingSibling1 + + void testPrecedingSibling2() + { + extraSetUp(); + XPathValue_t nodes = parser_.evaluate(SA::construct_from_utf8("/root/node()[last()]/preceding-sibling::text()"), document_); + assertEquals(2, nodes.asNodeSet().size()); + } // testPrecedingSibling2 + + void testPrecedingSibling3() + { + extraSetUp(); + XPathValue_t node = parser_.evaluate(SA::construct_from_utf8("/root/node()[last()]/preceding-sibling::text()[1]"), document_); + assertEquals("fourfive", node.asString()); + } // testPrecedingSibling3 + + void testPrecedingSibling4() + { + extraSetUp(); + XPathValue_t node = parser_.evaluate(SA::construct_from_utf8("/root/node()[last()]/preceding-sibling::text()[2]"), document_); + assertEquals("onetwothree", node.asString()); + } // testPrecedingSibling4 + // PRECEDING // PRECEDING_SIBLING }; // class TextNodeTest @@ -219,6 +273,14 @@ TestSuite* TextNodeTest_suite() suiteOfTests->addTest(new TestCaller >("testFollowing1", &TextNodeTest::testFollowing1)); suiteOfTests->addTest(new TestCaller >("testFollowing2", &TextNodeTest::testFollowing2)); suiteOfTests->addTest(new TestCaller >("testFollowing3", &TextNodeTest::testFollowing3)); + suiteOfTests->addTest(new TestCaller >("testPreceding1", &TextNodeTest::testPreceding1)); + suiteOfTests->addTest(new TestCaller >("testPreceding2", &TextNodeTest::testPreceding2)); + suiteOfTests->addTest(new TestCaller >("testPreceding3", &TextNodeTest::testPreceding3)); + suiteOfTests->addTest(new TestCaller >("testPreceding4", &TextNodeTest::testPreceding4)); + suiteOfTests->addTest(new TestCaller >("testPrecedingSibling1", &TextNodeTest::testPrecedingSibling1)); + suiteOfTests->addTest(new TestCaller >("testPrecedingSibling2", &TextNodeTest::testPrecedingSibling2)); + suiteOfTests->addTest(new TestCaller >("testPrecedingSibling3", &TextNodeTest::testPrecedingSibling3)); + suiteOfTests->addTest(new TestCaller >("testPrecedingSibling4", &TextNodeTest::testPrecedingSibling4)); return suiteOfTests; } // TextNodeTest