XPath: Fixed concat() crash
git-svn-id: http://pugixml.googlecode.com/svn/trunk@178 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
fb689fed2b
commit
3a9ba80368
@ -1208,7 +1208,7 @@ namespace pugi
|
|||||||
|
|
||||||
// tree node structure
|
// tree node structure
|
||||||
xpath_ast_node* m_left;
|
xpath_ast_node* m_left;
|
||||||
xpath_ast_node* m_right;
|
xpath_ast_node* m_right;
|
||||||
xpath_ast_node* m_third;
|
xpath_ast_node* m_third;
|
||||||
xpath_ast_node* m_next;
|
xpath_ast_node* m_next;
|
||||||
|
|
||||||
@ -1857,7 +1857,8 @@ namespace pugi
|
|||||||
else m_contents = 0;
|
else m_contents = 0;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
xpath_ast_node(ast_type_t type, const char* contents, xpath_allocator& a): m_type(type), m_rettype(ast_type_none), m_contents(0)
|
xpath_ast_node(ast_type_t type, const char* contents, xpath_allocator& a): m_type(type),
|
||||||
|
m_rettype(ast_type_none), m_left(0), m_right(0), m_third(0), m_next(0), m_contents(0)
|
||||||
{
|
{
|
||||||
set_contents(contents, a);
|
set_contents(contents, a);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,6 +47,7 @@ TEST_XML(xpath_number_sum, "<node>123<child>789</child></node><node/>")
|
|||||||
CHECK_XPATH_NUMBER(n, "sum(.)", 123789); // 123 .. 789
|
CHECK_XPATH_NUMBER(n, "sum(.)", 123789); // 123 .. 789
|
||||||
|
|
||||||
CHECK_XPATH_NUMBER(n, "sum(./descendant-or-self::node())", 125490); // node + 123 + child + 789 = 123789 + 123 + 789 + 789 = 125490
|
CHECK_XPATH_NUMBER(n, "sum(./descendant-or-self::node())", 125490); // node + 123 + child + 789 = 123789 + 123 + 789 + 789 = 125490
|
||||||
|
CHECK_XPATH_NUMBER(n, "sum(.//node())", 1701); // 123 + child + 789 = 123 + 789 + 789
|
||||||
CHECK_XPATH_NUMBER_NAN(doc.last_child(), "sum(.)");
|
CHECK_XPATH_NUMBER_NAN(doc.last_child(), "sum(.)");
|
||||||
|
|
||||||
// sum with 2 arguments
|
// sum with 2 arguments
|
||||||
@ -217,4 +218,27 @@ TEST_XML(xpath_boolean_lang, "<node xml:lang='en'><child xml:lang='ru-UK'><subch
|
|||||||
CHECK_XPATH_FAIL("lang(1, 2)");
|
CHECK_XPATH_FAIL("lang(1, 2)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(xpath_string_concat)
|
||||||
|
{
|
||||||
|
xml_node c;
|
||||||
|
|
||||||
|
// concat with 0 arguments
|
||||||
|
CHECK_XPATH_FAIL("concat()");
|
||||||
|
|
||||||
|
// concat with 1 argument
|
||||||
|
CHECK_XPATH_FAIL("concat('')");
|
||||||
|
|
||||||
|
// concat with exactly 2 arguments
|
||||||
|
CHECK_XPATH_STRING(c, "concat('prev','next')", "prevnext");
|
||||||
|
CHECK_XPATH_STRING(c, "concat('','next')", "next");
|
||||||
|
CHECK_XPATH_STRING(c, "concat('prev','')", "prev");
|
||||||
|
|
||||||
|
// concat with 3 or more arguments
|
||||||
|
CHECK_XPATH_STRING(c, "concat('a', 'b', 'c')", "abc");
|
||||||
|
CHECK_XPATH_STRING(c, "concat('a', 'b', 'c', 'd')", "abcd");
|
||||||
|
CHECK_XPATH_STRING(c, "concat('a', 'b', 'c', 'd', 'e')", "abcde");
|
||||||
|
CHECK_XPATH_STRING(c, "concat('a', 'b', 'c', 'd', 'e', 'f')", "abcdef");
|
||||||
|
CHECK_XPATH_STRING(c, "concat('a', 'b', 'c', 'd', 'e', 'f', 'g')", "abcdefg");
|
||||||
|
}
|
||||||
|
|
||||||
// $$$: string value of <node>123<child>789</child>100</node> should be 123789100 (?)
|
// $$$: string value of <node>123<child>789</child>100</node> should be 123789100 (?)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user