From 83183769c1125b3aa489205dd880bf94830831bd Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Wed, 28 Oct 2009 07:40:15 +0000 Subject: tests: Added function arguments tests, added arithmetic operators tests git-svn-id: http://pugixml.googlecode.com/svn/trunk@181 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_xpath_functions.cpp | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'tests/test_xpath_functions.cpp') diff --git a/tests/test_xpath_functions.cpp b/tests/test_xpath_functions.cpp index 67aa949..0a2b605 100644 --- a/tests/test_xpath_functions.cpp +++ b/tests/test_xpath_functions.cpp @@ -116,10 +116,6 @@ TEST(xpath_number_round) // round with 2 arguments CHECK_XPATH_FAIL("round(1, 2)"); - - // round with negative zero results - // $$ CHECK_XPATH_NUMBER(c, "round(-0.3)", -0) - // $$ CHECK_XPATH_NUMBER(c, "round(-0)", -0) } TEST_XML(xpath_boolean_boolean, "") @@ -498,3 +494,31 @@ TEST(xpath_string_translate) // translate with 4 arguments CHECK_XPATH_FAIL("translate('a', 'b', 'c', 'd')"); } + +TEST(xpath_function_arguments) +{ + xml_node c; + + // conversion to string + CHECK_XPATH_NUMBER(c, "string-length(12)", 2); + + // conversion to number + CHECK_XPATH_NUMBER(c, "round('1.2')", 1); + CHECK_XPATH_NUMBER(c, "round('1.7')", 2); + + // conversion to boolean + CHECK_XPATH_BOOLEAN(c, "not('1')", false); + CHECK_XPATH_BOOLEAN(c, "not('')", true); + + // conversion to node set + CHECK_XPATH_FAIL("sum(1)"); + + // expression evaluation + CHECK_XPATH_NUMBER(c, "round((2 + 2 * 2) div 4)", 2); + + // empty expressions + CHECK_XPATH_FAIL("round(,)"); + CHECK_XPATH_FAIL("substring(,)"); + CHECK_XPATH_FAIL("substring('a',)"); + CHECK_XPATH_FAIL("substring(,'a')"); +} -- cgit v1.2.3