From 050a633009d91f74e58a36f28b4de515b48c4341 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Tue, 3 Nov 2009 18:29:57 +0000 Subject: tests: Added helper for node set testing, added several tests git-svn-id: http://pugixml.googlecode.com/svn/trunk@200 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_xpath_functions.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'tests/test_xpath_functions.cpp') diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp index ef04667..e098813 100644 --- a/tests/test_xpath_functions.cpp +++ b/tests/test_xpath_functions.cpp @@ -498,6 +498,45 @@ TEST(xpath_string_translate) CHECK_XPATH_FAIL("translate('a', 'b', 'c', 'd')"); } +TEST_XML(xpath_nodeset_count, "") +{ + xml_node c; + xml_node n = doc.child("node"); + + // count with 0 arguments + CHECK_XPATH_FAIL("count()"); + + // count with 1 non-node-set argument + CHECK_XPATH_FAIL("count(1)"); + CHECK_XPATH_FAIL("count(true())"); + CHECK_XPATH_FAIL("count('')"); + + // count with 1 node-set argument + CHECK_XPATH_NUMBER(c, "count(.)", 0); + CHECK_XPATH_NUMBER(n, "count(.)", 1); + CHECK_XPATH_NUMBER(n, "count(c1)", 2); + CHECK_XPATH_NUMBER(n, "count(c2)", 1); + CHECK_XPATH_NUMBER(n, "count(c3)", 4); + CHECK_XPATH_NUMBER(n, "count(c4)", 0); + + // count with 2 arguments + CHECK_XPATH_FAIL("count(x, y)"); +} + +TEST_XML(xpath_nodeset_id, "") +{ + xml_node n = doc.child("node"); + + // id with 0 arguments + CHECK_XPATH_FAIL("id()"); + + // id with 1 argument - no DTD => no id + CHECK_XPATH_NODESET(n, "id('foo')"); + + // id with 2 arguments + CHECK_XPATH_FAIL("id(1, 2)"); +} + TEST(xpath_function_arguments) { xml_node c; -- cgit v1.2.3