diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-11-03 18:29:57 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-11-03 18:29:57 +0000 |
commit | 050a633009d91f74e58a36f28b4de515b48c4341 (patch) | |
tree | 02580f40ee0f666226cf26d051dd7d1f80b088be /tests/test_xpath_functions.cpp | |
parent | 04d4a6d9c2ab08246813da0ede46ba132f2c73ed (diff) |
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
Diffstat (limited to 'tests/test_xpath_functions.cpp')
-rw-r--r-- | tests/test_xpath_functions.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
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, "<node><c1/><c1/><c2/><c3/><c3/><c3/><c3/></node>")
+{
+ 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, "<node id='foo'/>")
+{
+ 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;
|