From ce974094ace6a33d46d8dcc6ca66a6fcdc014bbd Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sat, 21 Mar 2015 00:14:53 -0700 Subject: tests: Fix test compilation Rename PAGE_SIZE to page_size to avoid define conflict with Android SDK. Minor fixes in several tests. --- tests/allocator.cpp | 24 ++++++++++++------------ tests/test_header_only.cpp | 3 +++ tests/test_write.cpp | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'tests') 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(align_to_page(reinterpret_cast(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(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(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(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(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(""))); 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("")); + CHECK_NODE(doc, STR("")); node.set_value(STR("?>")); -- cgit v1.2.3