diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-10-21 20:46:42 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-10-21 20:46:42 +0000 |
commit | 9233e8605512d8ff887afbe6e55dc3db78e55ca9 (patch) | |
tree | 42cc7696c7b664899e22d656a1ce277af6f1c4a8 /tests | |
parent | 5cc45c82898304dad06f747a72b4663a0b22c015 (diff) |
tests: Added lang() tests
git-svn-id: http://pugixml.googlecode.com/svn/trunk@174 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_xpath_functions.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp index e4430f3..d033ab4 100644 --- a/tests/test_xpath_functions.cpp +++ b/tests/test_xpath_functions.cpp @@ -185,5 +185,35 @@ TEST(xpath_boolean_false) CHECK_XPATH_FAIL("false(1)");
}
+TEST_XML(xpath_boolean_lang, "<node xml:lang='en'><child xml:lang='ru-uk'><subchild/></child></node><foo><bar/></foo>")
+{
+ xml_node c;
+
+ // lang with 0 arguments
+ CHECK_XPATH_FAIL("lang()");
+
+ // lang with 1 argument, no language
+ CHECK_XPATH_BOOLEAN(c, "lang('en')", false);
+ CHECK_XPATH_BOOLEAN(doc.child("foo"), "lang('en')", false);
+ CHECK_XPATH_BOOLEAN(doc.child("foo"), "lang('')", false);
+ CHECK_XPATH_BOOLEAN(doc.child("foo").child("bar"), "lang('en')", false);
+
+ // lang with 1 argument, same language/prefix
+ CHECK_XPATH_BOOLEAN(doc.child("node"), "lang('en')", true);
+ CHECK_XPATH_BOOLEAN(doc.child("node").child("child"), "lang('ru-uk')", true);
+ CHECK_XPATH_BOOLEAN(doc.child("node").child("child"), "lang('ru')", true);
+ CHECK_XPATH_BOOLEAN(doc.child("node").child("child").child("subchild"), "lang('ru')", true);
+
+ // lang with 1 argument, different language/prefix
+ CHECK_XPATH_BOOLEAN(doc.child("node"), "lang('')", false);
+ CHECK_XPATH_BOOLEAN(doc.child("node"), "lang('e')", false);
+ CHECK_XPATH_BOOLEAN(doc.child("node").child("child"), "lang('en')", false);
+ CHECK_XPATH_BOOLEAN(doc.child("node").child("child"), "lang('ru-gb')", false);
+ CHECK_XPATH_BOOLEAN(doc.child("node").child("child"), "lang('r')", false);
+ CHECK_XPATH_BOOLEAN(doc.child("node").child("child").child("subchild"), "lang('en')", false);
+
+ // lang with 2 arguments
+ CHECK_XPATH_FAIL("lang(1, 2)");
+}
+
// $$$: string value of <node>123<child>789</child>100</node> should be 123789100 (?)
-// $$$: type -> node set conversion seems to be guarded via assert instead of exception
|