diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-12-19 10:16:37 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2010-12-19 10:16:37 +0000 |
commit | d99745be21ad9affc7e127944556c74da07440c4 (patch) | |
tree | b892303531af3f3775aeaa01799f2cb691a6d0f4 /tests | |
parent | 5720761685a1abc8ae0b5840a62359d35838ac3b (diff) |
Enabled many additional GCC warnings (most notably -Wshadow and -Wold-style-cast), fixed the code accordingly
git-svn-id: http://pugixml.googlecode.com/svn/trunk@800 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests')
-rw-r--r-- | tests/allocator.cpp | 14 | ||||
-rw-r--r-- | tests/main.cpp | 2 | ||||
-rw-r--r-- | tests/test.cpp | 2 | ||||
-rw-r--r-- | tests/test_document.cpp | 8 | ||||
-rw-r--r-- | tests/test_dom_modify.cpp | 6 | ||||
-rw-r--r-- | tests/test_dom_traverse.cpp | 6 | ||||
-rw-r--r-- | tests/test_parse_doctype.cpp | 8 | ||||
-rw-r--r-- | tests/test_xpath.cpp | 10 |
8 files changed, 28 insertions, 28 deletions
diff --git a/tests/allocator.cpp b/tests/allocator.cpp index b90820e..fcd8f2d 100644 --- a/tests/allocator.cpp +++ b/tests/allocator.cpp @@ -33,7 +33,7 @@ namespace void* result = HeapAlloc(heap, 0, size + PAGE_SIZE); - return (void*)align_to_page((size_t)result); + return reinterpret_cast<void*>(align_to_page(reinterpret_cast<size_t>(result))); } void* allocate(size_t size) @@ -43,19 +43,19 @@ namespace void* ptr = allocate_page_aligned(aligned_size + PAGE_SIZE); if (!ptr) return 0; - void* end = (char*)ptr + aligned_size; + char* end = static_cast<char*>(ptr) + aligned_size; DWORD old_flags; VirtualProtect(end, PAGE_SIZE, PAGE_NOACCESS, &old_flags); - return (char*)end - size; + return end - size; } void deallocate(void* ptr, size_t size) { size_t aligned_size = align_to_page(size); - void* rptr = (char*)ptr + size - aligned_size; + void* rptr = static_cast<char*>(ptr) + size - aligned_size; DWORD old_flags; VirtualProtect(rptr, aligned_size + PAGE_SIZE, PAGE_NOACCESS, &old_flags); @@ -88,13 +88,13 @@ void* memory_allocate(size_t size) memcpy(result, &size, sizeof(size_t)); - return (size_t*)result + 1; + return static_cast<size_t*>(result) + 1; } size_t memory_size(void* ptr) { size_t result; - memcpy(&result, (size_t*)ptr - 1, sizeof(size_t)); + memcpy(&result, static_cast<size_t*>(ptr) - 1, sizeof(size_t)); return result; } @@ -105,6 +105,6 @@ void memory_deallocate(void* ptr) size_t size = memory_size(ptr); - deallocate((size_t*)ptr - 1, size + sizeof(size_t)); + deallocate(static_cast<size_t*>(ptr) - 1, size + sizeof(size_t)); } diff --git a/tests/main.cpp b/tests/main.cpp index a8c5ae2..f974d0c 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -90,7 +90,7 @@ static bool run_test(test_runner* test) if (g_memory_total_size != 0 || g_memory_total_count != 0) { - printf("Test %s failed: memory leaks found (%u bytes in %u allocations)\n", test->_name, (unsigned int)g_memory_total_size, (unsigned int)g_memory_total_count); + printf("Test %s failed: memory leaks found (%u bytes in %u allocations)\n", test->_name, static_cast<unsigned int>(g_memory_total_size), static_cast<unsigned int>(g_memory_total_count)); return false; } diff --git a/tests/test.cpp b/tests/test.cpp index 0295cad..33c7fb5 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -141,7 +141,7 @@ void xpath_node_set_tester::check(bool condition) } } -xpath_node_set_tester::xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message): last(0), message(message) +xpath_node_set_tester::xpath_node_set_tester(const pugi::xpath_node_set& set, const char* message_): last(0), message(message_) { result = set; diff --git a/tests/test_document.cpp b/tests/test_document.cpp index 971bb48..11057ae 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -429,7 +429,7 @@ TEST(document_parse_result_bool) for (int i = 1; i < 20; ++i) { - result.status = (xml_parse_status)i; + result.status = static_cast<xml_parse_status>(i); CHECK(!result); CHECK(result == false); } @@ -441,7 +441,7 @@ TEST(document_parse_result_description) for (int i = 0; i < 20; ++i) { - result.status = (xml_parse_status)i; + result.status = static_cast<xml_parse_status>(i); CHECK(result.description() != 0); CHECK(result.description()[0] != 0); @@ -461,7 +461,7 @@ inline void check_utftest_document(const xml_document& doc) CHECK_STRING(doc.last_child().first_child().name(), STR("English")); // check that we have parsed some non-ascii text - CHECK((unsigned)doc.last_child().last_child().name()[0] >= 0x80); + CHECK(static_cast<unsigned int>(doc.last_child().last_child().name()[0]) >= 0x80); // check magic string const pugi::char_t* v = doc.last_child().child(STR("Heavy")).previous_sibling().child_value(); @@ -645,7 +645,7 @@ static bool load_file_in_memory(const char* path, char*& data, size_t& size) if (!file) return false; fseek(file, 0, SEEK_END); - size = (size_t)ftell(file); + size = static_cast<size_t>(ftell(file)); fseek(file, 0, SEEK_SET); data = new char[size]; diff --git a/tests/test_dom_modify.cpp b/tests/test_dom_modify.cpp index 70a01cc..a63435c 100644 --- a/tests/test_dom_modify.cpp +++ b/tests/test_dom_modify.cpp @@ -1,6 +1,6 @@ #include "common.hpp" -#include <float.h> +#include <limits> TEST_XML(dom_attr_assign, "<node/>") { @@ -707,8 +707,8 @@ TEST_XML(dom_attr_assign_large_number, "<node attr1='' attr2='' />") { xml_node node = doc.child(STR("node")); - node.attribute(STR("attr1")) = FLT_MAX; - node.attribute(STR("attr2")) = DBL_MAX; + node.attribute(STR("attr1")) = std::numeric_limits<float>::max(); + node.attribute(STR("attr2")) = std::numeric_limits<double>::max(); CHECK(test_node(node, STR("<node attr1=\"3.40282e+038\" attr2=\"1.79769e+308\" />"), STR(""), pugi::format_raw) || test_node(node, STR("<node attr1=\"3.40282e+38\" attr2=\"1.79769e+308\" />"), STR(""), pugi::format_raw)); diff --git a/tests/test_dom_traverse.cpp b/tests/test_dom_traverse.cpp index 0ee87ed..d62cce0 100644 --- a/tests/test_dom_traverse.cpp +++ b/tests/test_dom_traverse.cpp @@ -490,7 +490,7 @@ struct find_predicate_const { bool result; - find_predicate_const(bool result): result(result) + find_predicate_const(bool result_): result(result_) { } @@ -504,7 +504,7 @@ struct find_predicate_prefix { const pugi::char_t* prefix; - find_predicate_prefix(const pugi::char_t* prefix): prefix(prefix) + find_predicate_prefix(const pugi::char_t* prefix_): prefix(prefix_) { } @@ -616,7 +616,7 @@ struct test_walker: xml_tree_walker unsigned int call_count; unsigned int stop_count; - test_walker(unsigned int stop_count = 0): call_count(0), stop_count(stop_count) + test_walker(unsigned int stop_count_ = 0): call_count(0), stop_count(stop_count_) { } diff --git a/tests/test_parse_doctype.cpp b/tests/test_parse_doctype.cpp index 2a092d9..d7a3726 100644 --- a/tests/test_parse_doctype.cpp +++ b/tests/test_parse_doctype.cpp @@ -28,12 +28,12 @@ static bool test_doctype_wf(const char_t* decl) xml_document doc; // standalone - if (!load_concat(doc, decl) || (bool)doc.first_child()) return false; + if (!load_concat(doc, decl) || !doc.first_child().empty()) return false; // pcdata pre/postfix - if (!load_concat(doc, STR("a"), decl) || (bool)doc.first_child()) return false; - if (!load_concat(doc, decl, STR("b")) || (bool)doc.first_child()) return false; - if (!load_concat(doc, STR("a"), decl, STR("b")) || (bool)doc.first_child()) return false; + if (!load_concat(doc, STR("a"), decl) || !doc.first_child().empty()) return false; + if (!load_concat(doc, decl, STR("b")) || !doc.first_child().empty()) return false; + if (!load_concat(doc, STR("a"), decl, STR("b")) || !doc.first_child().empty()) return false; // node pre/postfix if (!load_concat(doc, STR("<nodea/>"), decl) || !test_node(doc, STR("<nodea />"), STR(""), format_raw)) return false; diff --git a/tests/test_xpath.cpp b/tests/test_xpath.cpp index 30ff8a1..0416841 100644 --- a/tests/test_xpath.cpp +++ b/tests/test_xpath.cpp @@ -2,13 +2,13 @@ #include "common.hpp" -#include <float.h> #include <string.h> #include <wchar.h> #include <string> #include <vector> #include <algorithm> +#include <limits> static void load_document_copy(xml_document& doc, const char_t* text) { @@ -162,10 +162,10 @@ TEST(xpath_long_numbers_parse) xml_node c; // check parsing - CHECK_XPATH_NUMBER(c, str_flt_max, FLT_MAX); - CHECK_XPATH_NUMBER(c, str_flt_max_dec, FLT_MAX); - CHECK_XPATH_NUMBER(c, str_dbl_max, DBL_MAX); - CHECK_XPATH_NUMBER(c, str_dbl_max_dec, DBL_MAX); + CHECK_XPATH_NUMBER(c, str_flt_max, std::numeric_limits<float>::max()); + CHECK_XPATH_NUMBER(c, str_flt_max_dec, std::numeric_limits<float>::max()); + CHECK_XPATH_NUMBER(c, str_dbl_max, std::numeric_limits<double>::max()); + CHECK_XPATH_NUMBER(c, str_dbl_max_dec, std::numeric_limits<double>::max()); } 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) |