summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-03-21 00:14:53 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-03-21 00:14:53 -0700
commitce974094ace6a33d46d8dcc6ca66a6fcdc014bbd (patch)
treea6c2f594cbc04bd2042dd55c66afc23f51f9b14c
parent28e63f66e1e947de276a2181b28906528a483037 (diff)
tests: Fix test compilation
Rename PAGE_SIZE to page_size to avoid define conflict with Android SDK. Minor fixes in several tests.
-rw-r--r--tests/allocator.cpp24
-rw-r--r--tests/test_header_only.cpp3
-rw-r--r--tests/test_write.cpp2
3 files changed, 16 insertions, 13 deletions
diff --git a/tests/allocator.cpp b/tests/allocator.cpp
index 74bbf10..8ca0963 100644
--- a/tests/allocator.cpp
+++ b/tests/allocator.cpp
@@ -23,11 +23,11 @@
namespace
{
- const size_t PAGE_SIZE = 4096;
+ const size_t page_size = 4096;
size_t align_to_page(size_t value)
{
- return (value + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+ return (value + page_size - 1) & ~(page_size - 1);
}
void* allocate_page_aligned(size_t size)
@@ -36,7 +36,7 @@ namespace
// We can't use malloc because of occasional problems with CW on CRT termination
static HANDLE heap = HeapCreate(0, 0, 0);
- void* result = HeapAlloc(heap, 0, size + PAGE_SIZE);
+ void* result = HeapAlloc(heap, 0, size + page_size);
return reinterpret_cast<void*>(align_to_page(reinterpret_cast<size_t>(result)));
}
@@ -45,13 +45,13 @@ namespace
{
size_t aligned_size = align_to_page(size);
- void* ptr = allocate_page_aligned(aligned_size + PAGE_SIZE);
+ void* ptr = allocate_page_aligned(aligned_size + page_size);
if (!ptr) return 0;
char* end = static_cast<char*>(ptr) + aligned_size;
DWORD old_flags;
- VirtualProtect(end, PAGE_SIZE, PAGE_NOACCESS, &old_flags);
+ VirtualProtect(end, page_size, PAGE_NOACCESS, &old_flags);
return end - size;
}
@@ -63,7 +63,7 @@ namespace
void* rptr = static_cast<char*>(ptr) + size - aligned_size;
DWORD old_flags;
- VirtualProtect(rptr, aligned_size + PAGE_SIZE, PAGE_NOACCESS, &old_flags);
+ VirtualProtect(rptr, aligned_size + page_size, PAGE_NOACCESS, &old_flags);
}
}
#elif defined(__APPLE__) || defined(__linux__)
@@ -71,28 +71,28 @@ namespace
namespace
{
- const size_t PAGE_SIZE = 4096;
+ const size_t page_size = 4096;
size_t align_to_page(size_t value)
{
- return (value + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+ return (value + page_size - 1) & ~(page_size - 1);
}
void* allocate_page_aligned(size_t size)
{
- return mmap(0, size + PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+ return mmap(0, size + page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
}
void* allocate(size_t size)
{
size_t aligned_size = align_to_page(size);
- void* ptr = allocate_page_aligned(aligned_size + PAGE_SIZE);
+ void* ptr = allocate_page_aligned(aligned_size + page_size);
if (!ptr) return 0;
char* end = static_cast<char*>(ptr) + aligned_size;
- int res = mprotect(end, PAGE_SIZE, PROT_NONE);
+ int res = mprotect(end, page_size, PROT_NONE);
assert(res == 0);
(void)!res;
@@ -105,7 +105,7 @@ namespace
void* rptr = static_cast<char*>(ptr) + size - aligned_size;
- int res = mprotect(rptr, aligned_size + PAGE_SIZE, PROT_NONE);
+ int res = mprotect(rptr, aligned_size + page_size, PROT_NONE);
assert(res == 0);
(void)!res;
}
diff --git a/tests/test_header_only.cpp b/tests/test_header_only.cpp
index f1990dd..17cafca 100644
--- a/tests/test_header_only.cpp
+++ b/tests/test_header_only.cpp
@@ -12,5 +12,8 @@ TEST(header_only)
xml_document doc;
CHECK(doc.load_string(STR("<node/>")));
CHECK_STRING(doc.first_child().name(), STR("node"));
+
+#ifndef PUGIXML_NO_XPATH
CHECK(doc.first_child() == doc.select_node(STR("//*")).node());
+#endif
}
diff --git a/tests/test_write.cpp b/tests/test_write.cpp
index 1528453..ad6c409 100644
--- a/tests/test_write.cpp
+++ b/tests/test_write.cpp
@@ -123,7 +123,7 @@ TEST(write_pi_invalid)
node.set_name(STR("test"));
node.set_value(STR("?"));
- CHECK_NODE(doc, STR("<?test ?" "?>"));
+ CHECK_NODE(doc, STR("<?test ?") STR("?>"));
node.set_value(STR("?>"));