summaryrefslogtreecommitdiff
path: root/tests/test_xpath_parse.cpp
blob: cce30858b8671fcec4fe5985223b81228ee137dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef PUGIXML_NO_XPATH

#include "common.hpp"

TEST(xpath_literal_parse)
{
	xml_node c;
	CHECK_XPATH_STRING(c, "'a\"b'", "a\"b");
	CHECK_XPATH_STRING(c, "\"a'b\"", "a'b");
	CHECK_XPATH_STRING(c, "\"\"", "");
	CHECK_XPATH_STRING(c, "\'\'", "");
}

TEST(xpath_literal_error)
{
	CHECK_XPATH_FAIL("\"");
	CHECK_XPATH_FAIL("\'");
}

TEST(xpath_number_parse)
{
	xml_node c;
	CHECK_XPATH_NUMBER(c, "0", 0);
	CHECK_XPATH_NUMBER(c, "123", 123);
	CHECK_XPATH_NUMBER(c, "123.456", 123.456);
	CHECK_XPATH_NUMBER(c, ".123", 0.123);
	CHECK_XPATH_NUMBER(c, "123.4567890123456789012345", 123.4567890123456789012345);
}

TEST(xpath_number_error)
{
	CHECK_XPATH_FAIL("123a");
	CHECK_XPATH_FAIL("123.a");
	CHECK_XPATH_FAIL(".123a");
}

TEST(xpath_variables)
{
	CHECK_XPATH_FAIL("$var"); // not implemented
}

TEST(xpath_empty_expression)
{
	CHECK_XPATH_FAIL("");
}

TEST(xpath_lexer_error)
{
	CHECK_XPATH_FAIL("!");
}

#endif