summaryrefslogtreecommitdiff
path: root/tests/test_xpath.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:25:05 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:25:05 +0000
commit049fa3906db2786943617bb1b0ce3225be9a772f (patch)
tree3a502c3c0f3e93f4f3b3022eb13aa2e0bdf47705 /tests/test_xpath.cpp
parent91777e5c172c401ff25bd5a37067c5caca78dc63 (diff)
tests: Added new evaluate_string tests, fixed tests for NO_STL mode
git-svn-id: http://pugixml.googlecode.com/svn/trunk@661 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_xpath.cpp')
-rw-r--r--tests/test_xpath.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp
index 7db9ea5..a2e8200 100644
--- a/tests/test_xpath.cpp
+++ b/tests/test_xpath.cpp
@@ -18,7 +18,7 @@ static void load_document_copy(xml_document& doc, const char_t* text)
TEST(xpath_allocator_many_pages)
{
- pugi::string_t query = STR("0");
+ std::basic_string<char_t> query = STR("0");
for (int i = 0; i < 128; ++i) query += STR("+string-length('abcdefgh')");
@@ -27,7 +27,7 @@ TEST(xpath_allocator_many_pages)
TEST(xpath_allocator_large_page)
{
- pugi::string_t query;
+ std::basic_string<char_t> query;
for (int i = 0; i < 1024; ++i) query += STR("abcdefgh");
@@ -139,16 +139,14 @@ TEST(xpath_long_numbers_parse)
static bool test_xpath_string_prefix(const pugi::xml_node& node, const pugi::char_t* query, const pugi::char_t* expected, size_t match_length)
{
-#ifdef PUGIXML_WCHAR_MODE
- size_t expected_length = wcslen(expected);
-#else
- size_t expected_length = strlen(expected);
-#endif
-
pugi::xpath_query q(query);
- pugi::string_t value = q.evaluate_string(node);
- return value.length() == expected_length && value.compare(0, match_length, expected, match_length) == 0;
+ pugi::char_t result[32];
+ size_t size = q.evaluate_string(result, sizeof(result) / sizeof(result[0]), node);
+
+ size_t expected_length = std::char_traits<pugi::char_t>::length(expected);
+
+ return size == expected_length + 1 && std::char_traits<pugi::char_t>::compare(result, expected, match_length) == 0;
}
TEST(xpath_long_numbers_stringize)
@@ -170,7 +168,7 @@ TEST(xpath_long_numbers_stringize)
TEST(xpath_denorm_numbers)
{
- pugi::string_t query;
+ std::basic_string<pugi::char_t> query;
// 10^-318 - double denormal
for (int i = 0; i < 106; ++i)