summaryrefslogtreecommitdiff
path: root/tests/test.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:49:06 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:49:06 +0000
commit998a534df7232c142521c57e7abd5e366ac3a8eb (patch)
tree90a55d6548e69ebaf84529ec0622f04237bba4b2 /tests/test.cpp
parent6d44879c5a01c10f8ce6687fa01676753225be7b (diff)
tests: Changed XPath checking macros to avoid query copying under GCC
git-svn-id: http://pugixml.googlecode.com/svn/trunk@692 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test.cpp')
-rw-r--r--tests/test.cpp56
1 files changed, 20 insertions, 36 deletions
diff --git a/tests/test.cpp b/tests/test.cpp
index a48ef48..0295cad 100644
--- a/tests/test.cpp
+++ b/tests/test.cpp
@@ -70,65 +70,49 @@ bool test_double_nan(double value)
}
#ifndef PUGIXML_NO_XPATH
-bool test_xpath_string(const pugi::xpath_node& node, const pugi::xpath_query& query, const pugi::char_t* expected)
+bool test_xpath_string(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, const pugi::char_t* expected)
{
+ pugi::xpath_query q(query, variables);
+ if (!q) return false;
+
const size_t capacity = 64;
pugi::char_t result[capacity];
- size_t size = query.evaluate_string(result, capacity, node);
+ size_t size = q.evaluate_string(result, capacity, node);
if (size <= capacity) return test_string_equal(result, expected);
std::basic_string<pugi::char_t> buffer(size, ' ');
- return query.evaluate_string(&buffer[0], size, node) == size && test_string_equal(buffer.c_str(), expected);
+ return q.evaluate_string(&buffer[0], size, node) == size && test_string_equal(buffer.c_str(), expected);
}
-bool test_xpath_boolean(const pugi::xpath_node& node, const pugi::xpath_query& query, bool expected)
+bool test_xpath_boolean(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, bool expected)
{
- return query.evaluate_boolean(node) == expected;
+ pugi::xpath_query q(query, variables);
+ if (!q) return false;
+
+ return q.evaluate_boolean(node) == expected;
}
-bool test_xpath_number(const pugi::xpath_node& node, const pugi::xpath_query& query, double expected)
+bool test_xpath_number(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables, double expected)
{
- double value = query.evaluate_number(node);
+ pugi::xpath_query q(query, variables);
+ if (!q) return false;
+
+ double value = q.evaluate_number(node);
double absolute_error = fabs(value - expected);
const double tolerance = 1e-15f;
return absolute_error < tolerance || absolute_error < fabs(expected) * tolerance;
}
-bool test_xpath_number_nan(const pugi::xpath_node& node, const pugi::xpath_query& query)
-{
- return test_double_nan(query.evaluate_number(node));
-}
-
-bool test_xpath_string(const pugi::xpath_node& node, const pugi::char_t* query, const pugi::char_t* expected)
-{
- pugi::xpath_query q(query);
-
- return q && test_xpath_string(node, q, expected);
-}
-
-bool test_xpath_boolean(const pugi::xpath_node& node, const pugi::char_t* query, bool expected)
-{
- pugi::xpath_query q(query);
-
- return q && test_xpath_boolean(node, q, expected);
-}
-
-bool test_xpath_number(const pugi::xpath_node& node, const pugi::char_t* query, double expected)
-{
- pugi::xpath_query q(query);
-
- return q && test_xpath_number(node, q, expected);
-}
-
-bool test_xpath_number_nan(const pugi::xpath_node& node, const pugi::char_t* query)
+bool test_xpath_number_nan(const pugi::xpath_node& node, const pugi::char_t* query, pugi::xpath_variable_set* variables)
{
- pugi::xpath_query q(query);
+ pugi::xpath_query q(query, variables);
+ if (!q) return false;
- return q && test_xpath_number_nan(node, q);
+ return test_double_nan(q.evaluate_number(node));
}
bool test_xpath_fail_compile(const pugi::char_t* query, pugi::xpath_variable_set* variables)