From 4b371e10eed49d25bf4240a6aaa321b084e586ea Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Thu, 22 Jun 2017 20:33:02 -0700 Subject: tests: Remove redundant pugi:: qualifier Most tests have `using namespace pugi` which makes explicit qualifications unnecessary. --- tests/test_document.cpp | 132 ++++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 66 deletions(-) (limited to 'tests/test_document.cpp') diff --git a/tests/test_document.cpp b/tests/test_document.cpp index fd376bb..45b8536 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -60,13 +60,13 @@ static bool test_file_contents(const char* path, const char* data, size_t size) TEST(document_create_empty) { - pugi::xml_document doc; + xml_document doc; CHECK_NODE(doc, STR("")); } TEST(document_create) { - pugi::xml_document doc; + xml_document doc; doc.append_child().set_name(STR("node")); CHECK_NODE(doc, STR("")); } @@ -74,7 +74,7 @@ TEST(document_create) #ifndef PUGIXML_NO_STL TEST(document_load_stream) { - pugi::xml_document doc; + xml_document doc; std::istringstream iss(""); CHECK(doc.load(iss)); @@ -83,7 +83,7 @@ TEST(document_load_stream) TEST(document_load_stream_offset) { - pugi::xml_document doc; + xml_document doc; std::istringstream iss(" "); @@ -96,7 +96,7 @@ TEST(document_load_stream_offset) TEST(document_load_stream_text) { - pugi::xml_document doc; + xml_document doc; std::ifstream iss("tests/data/multiline.xml"); CHECK(doc.load(iss)); @@ -105,7 +105,7 @@ TEST(document_load_stream_text) TEST(document_load_stream_error) { - pugi::xml_document doc; + xml_document doc; std::ifstream fs("filedoesnotexist"); CHECK(doc.load(fs).status == status_io_error); @@ -113,7 +113,7 @@ TEST(document_load_stream_error) TEST(document_load_stream_out_of_memory) { - pugi::xml_document doc; + xml_document doc; std::istringstream iss(""); test_runner::_memory_fail_threshold = 1; @@ -122,7 +122,7 @@ TEST(document_load_stream_out_of_memory) TEST(document_load_stream_wide_out_of_memory) { - pugi::xml_document doc; + xml_document doc; std::basic_istringstream iss(L""); test_runner::_memory_fail_threshold = 1; @@ -133,14 +133,14 @@ TEST(document_load_stream_empty) { std::istringstream iss; - pugi::xml_document doc; + xml_document doc; doc.load(iss); // parse result depends on STL implementation CHECK(!doc.first_child()); } TEST(document_load_stream_wide) { - pugi::xml_document doc; + xml_document doc; std::basic_istringstream iss(L""); CHECK(doc.load(iss)); @@ -150,7 +150,7 @@ TEST(document_load_stream_wide) #ifndef PUGIXML_NO_EXCEPTIONS TEST(document_load_stream_exceptions) { - pugi::xml_document doc; + xml_document doc; // Windows has newline translation for text-mode files, so reading from this stream reaches eof and sets fail|eof bits. // This test does not cause stream to throw an exception on Linux - I have no idea how to get read() to fail except @@ -173,7 +173,7 @@ TEST(document_load_stream_exceptions) TEST(document_load_stream_error_previous) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_string(STR(""))); CHECK(doc.first_child()); @@ -184,7 +184,7 @@ TEST(document_load_stream_error_previous) TEST(document_load_stream_wide_error_previous) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_string(STR(""))); CHECK(doc.first_child()); @@ -208,7 +208,7 @@ TEST(document_load_stream_nonseekable) char_array_buffer buffer(contents, contents + sizeof(contents) / sizeof(contents[0])); std::istream in(&buffer); - pugi::xml_document doc; + xml_document doc; CHECK(doc.load(in)); CHECK_NODE(doc, STR("")); } @@ -219,22 +219,22 @@ TEST(document_load_stream_wide_nonseekable) char_array_buffer buffer(contents, contents + sizeof(contents) / sizeof(contents[0])); std::basic_istream in(&buffer); - pugi::xml_document doc; + xml_document doc; CHECK(doc.load(in)); CHECK_NODE(doc, STR("")); } TEST(document_load_stream_nonseekable_large) { - std::basic_string str; + std::basic_string str; str += STR(""); for (int i = 0; i < 10000; ++i) str += STR(""); str += STR(""); - char_array_buffer buffer(&str[0], &str[0] + str.length()); - std::basic_istream in(&buffer); + char_array_buffer buffer(&str[0], &str[0] + str.length()); + std::basic_istream in(&buffer); - pugi::xml_document doc; + xml_document doc; CHECK(doc.load(in)); CHECK_NODE(doc, str.c_str()); } @@ -247,7 +247,7 @@ TEST(document_load_stream_nonseekable_out_of_memory) test_runner::_memory_fail_threshold = 1; - pugi::xml_document doc; + xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); } @@ -259,7 +259,7 @@ TEST(document_load_stream_wide_nonseekable_out_of_memory) test_runner::_memory_fail_threshold = 1; - pugi::xml_document doc; + xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); } @@ -275,7 +275,7 @@ TEST(document_load_stream_nonseekable_out_of_memory_large) test_runner::_memory_fail_threshold = 10000 * 8 * 3 / 2; - pugi::xml_document doc; + xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); } @@ -291,7 +291,7 @@ TEST(document_load_stream_wide_nonseekable_out_of_memory_large) test_runner::_memory_fail_threshold = 10000 * 8 * 3 / 2; - pugi::xml_document doc; + xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); } @@ -310,7 +310,7 @@ TEST(document_load_stream_seekable_fail_seek) seek_fail_buffer buffer; std::basic_istream in(&buffer); - pugi::xml_document doc; + xml_document doc; CHECK(doc.load(in).status == status_io_error); } @@ -319,14 +319,14 @@ TEST(document_load_stream_wide_seekable_fail_seek) seek_fail_buffer buffer; std::basic_istream in(&buffer); - pugi::xml_document doc; + xml_document doc; CHECK(doc.load(in).status == status_io_error); } #endif TEST(document_load_string) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_string(STR(""))); CHECK_NODE(doc, STR("")); @@ -334,7 +334,7 @@ TEST(document_load_string) TEST(document_load_file) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_file("tests/data/small.xml")); CHECK_NODE(doc, STR("")); @@ -342,7 +342,7 @@ TEST(document_load_file) TEST(document_load_file_empty) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_file("tests/data/empty.xml").status == status_no_document_element); CHECK(!doc.first_child()); @@ -350,11 +350,11 @@ TEST(document_load_file_empty) TEST(document_load_file_large) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_file("tests/data/large.xml")); - std::basic_string str; + std::basic_string str; str += STR(""); for (int i = 0; i < 10000; ++i) str += STR(""); str += STR(""); @@ -364,7 +364,7 @@ TEST(document_load_file_large) TEST(document_load_file_error) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_file("filedoesnotexist").status == status_file_not_found); } @@ -373,7 +373,7 @@ TEST(document_load_file_out_of_memory) { test_runner::_memory_fail_threshold = 1; - pugi::xml_document doc; + xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.load_file("tests/data/small.xml").status == status_out_of_memory)); } @@ -381,7 +381,7 @@ TEST(document_load_file_out_of_memory_file_leak) { test_runner::_memory_fail_threshold = 1; - pugi::xml_document doc; + xml_document doc; for (int i = 0; i < 256; ++i) CHECK_ALLOC_FAIL(CHECK(doc.load_file("tests/data/small.xml").status == status_out_of_memory)); @@ -396,7 +396,7 @@ TEST(document_load_file_wide_out_of_memory_file_leak) { test_runner::_memory_fail_threshold = 256; - pugi::xml_document doc; + xml_document doc; for (int i = 0; i < 256; ++i) CHECK_ALLOC_FAIL(CHECK(doc.load_file(L"tests/data/small.xml").status == status_out_of_memory)); @@ -409,7 +409,7 @@ TEST(document_load_file_wide_out_of_memory_file_leak) TEST(document_load_file_error_previous) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_string(STR(""))); CHECK(doc.first_child()); @@ -419,7 +419,7 @@ TEST(document_load_file_error_previous) TEST(document_load_file_wide_ascii) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_file(L"tests/data/small.xml")); CHECK_NODE(doc, STR("")); @@ -428,7 +428,7 @@ TEST(document_load_file_wide_ascii) #if !defined(__DMC__) && !defined(__MWERKS__) && !(defined(__MINGW32__) && defined(__STRICT_ANSI__) && !defined(__MINGW64_VERSION_MAJOR)) && !defined(__BORLANDC__) TEST(document_load_file_wide_unicode) { - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_file(L"tests/data/\x0442\x0435\x0441\x0442.xml")); CHECK_NODE(doc, STR("")); @@ -439,9 +439,9 @@ TEST(document_load_file_wide_out_of_memory) { test_runner::_memory_fail_threshold = 1; - pugi::xml_document doc; + xml_document doc; - pugi::xml_parse_result result; + xml_parse_result result; result.status = status_out_of_memory; CHECK_ALLOC_FAIL(result = doc.load_file(L"tests/data/small.xml")); @@ -469,7 +469,7 @@ TEST_XML(document_save, "") { xml_writer_string writer; - doc.save(writer, STR(""), pugi::format_no_declaration | pugi::format_raw, get_native_encoding()); + doc.save(writer, STR(""), format_no_declaration | format_raw, get_native_encoding()); CHECK(writer.as_string() == STR("")); } @@ -479,7 +479,7 @@ TEST_XML(document_save_stream, "") { std::ostringstream oss; - doc.save(oss, STR(""), pugi::format_no_declaration | pugi::format_raw); + doc.save(oss, STR(""), format_no_declaration | format_raw); CHECK(oss.str() == ""); } @@ -488,7 +488,7 @@ TEST_XML(document_save_stream_wide, "") { std::basic_ostringstream oss; - doc.save(oss, STR(""), pugi::format_no_declaration | pugi::format_raw); + doc.save(oss, STR(""), format_no_declaration | format_raw); CHECK(oss.str() == L""); } @@ -518,7 +518,7 @@ TEST_XML(document_save_declaration, "") { xml_writer_string writer; - doc.save(writer, STR(""), pugi::format_default, get_native_encoding()); + doc.save(writer, STR(""), format_default, get_native_encoding()); CHECK(writer.as_string() == STR("\n\n")); } @@ -529,7 +529,7 @@ TEST(document_save_declaration_empty) xml_writer_string writer; - doc.save(writer, STR(""), pugi::format_default, get_native_encoding()); + doc.save(writer, STR(""), format_default, get_native_encoding()); CHECK(writer.as_string() == STR("\n")); } @@ -540,7 +540,7 @@ TEST_XML(document_save_declaration_present_first, "") xml_writer_string writer; - doc.save(writer, STR(""), pugi::format_default, get_native_encoding()); + doc.save(writer, STR(""), format_default, get_native_encoding()); CHECK(writer.as_string() == STR("\n\n")); } @@ -552,7 +552,7 @@ TEST_XML(document_save_declaration_present_second, "") xml_writer_string writer; - doc.save(writer, STR(""), pugi::format_default, get_native_encoding()); + doc.save(writer, STR(""), format_default, get_native_encoding()); CHECK(writer.as_string() == STR("\n\n\n")); } @@ -563,7 +563,7 @@ TEST_XML(document_save_declaration_present_last, "") xml_writer_string writer; - doc.save(writer, STR(""), pugi::format_default, get_native_encoding()); + doc.save(writer, STR(""), format_default, get_native_encoding()); // node writer only looks for declaration before the first element child CHECK(writer.as_string() == STR("\n\n\n")); @@ -573,7 +573,7 @@ TEST_XML(document_save_declaration_latin1, "") { xml_writer_string writer; - doc.save(writer, STR(""), pugi::format_default, encoding_latin1); + doc.save(writer, STR(""), format_default, encoding_latin1); CHECK(writer.as_narrow() == "\n\n"); } @@ -582,7 +582,7 @@ TEST_XML(document_save_declaration_raw, "") { xml_writer_string writer; - doc.save(writer, STR(""), pugi::format_raw, get_native_encoding()); + doc.save(writer, STR(""), format_raw, get_native_encoding()); CHECK(writer.as_string() == STR("")); } @@ -611,7 +611,7 @@ TEST_XML(document_save_file, "") CHECK(doc.save_file(f.path)); - CHECK(doc.load_file(f.path, pugi::parse_default | pugi::parse_declaration)); + CHECK(doc.load_file(f.path, parse_default | parse_declaration)); CHECK_NODE(doc, STR("")); } @@ -625,7 +625,7 @@ TEST_XML(document_save_file_wide, "") CHECK(doc.save_file(wpath)); - CHECK(doc.load_file(f.path, pugi::parse_default | pugi::parse_declaration)); + CHECK(doc.load_file(f.path, parse_default | parse_declaration)); CHECK_NODE(doc, STR("")); } @@ -638,10 +638,10 @@ TEST_XML(document_save_file_text, "") { temp_file f; - CHECK(doc.save_file(f.path, STR(""), pugi::format_no_declaration | pugi::format_save_file_text)); + CHECK(doc.save_file(f.path, STR(""), format_no_declaration | format_save_file_text)); CHECK(test_file_contents(f.path, "\n", 9) || test_file_contents(f.path, "\r\n", 10)); - CHECK(doc.save_file(f.path, STR(""), pugi::format_no_declaration)); + CHECK(doc.save_file(f.path, STR(""), format_no_declaration)); CHECK(test_file_contents(f.path, "\n", 9)); } @@ -653,10 +653,10 @@ TEST_XML(document_save_file_wide_text, "") wchar_t wpath[sizeof(f.path)]; std::copy(f.path, f.path + strlen(f.path) + 1, wpath + 0); - CHECK(doc.save_file(wpath, STR(""), pugi::format_no_declaration | pugi::format_save_file_text)); + CHECK(doc.save_file(wpath, STR(""), format_no_declaration | format_save_file_text)); CHECK(test_file_contents(f.path, "\n", 9) || test_file_contents(f.path, "\r\n", 10)); - CHECK(doc.save_file(wpath, STR(""), pugi::format_no_declaration)); + CHECK(doc.save_file(wpath, STR(""), format_no_declaration)); CHECK(test_file_contents(f.path, "\n", 9)); } @@ -682,9 +682,9 @@ TEST_XML(document_save_file_wide_leak, "") TEST(document_load_buffer) { - const pugi::char_t text[] = STR(""); + const char_t text[] = STR(""); - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_buffer(text, sizeof(text))); CHECK_NODE(doc, STR("")); @@ -692,9 +692,9 @@ TEST(document_load_buffer) TEST(document_load_buffer_inplace) { - pugi::char_t text[] = STR(""); + char_t text[] = STR(""); - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_buffer_inplace(text, sizeof(text))); CHECK_NODE(doc, STR("")); @@ -704,14 +704,14 @@ TEST(document_load_buffer_inplace_own) { allocation_function alloc = get_memory_allocation_function(); - size_t size = strlen("") * sizeof(pugi::char_t); + size_t size = strlen("") * sizeof(char_t); - pugi::char_t* text = static_cast(alloc(size)); + char_t* text = static_cast(alloc(size)); CHECK(text); memcpy(text, STR(""), size); - pugi::xml_document doc; + xml_document doc; CHECK(doc.load_buffer_inplace_own(text, size)); CHECK_NODE(doc, STR("")); @@ -763,7 +763,7 @@ inline void check_utftest_document(const xml_document& doc) CHECK(static_cast(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(); + const char_t* v = doc.last_child().child(STR("Heavy")).previous_sibling().child_value(); #ifdef PUGIXML_WCHAR_MODE CHECK(v[0] == 0x4e16 && v[1] == 0x754c && v[2] == 0x6709 && v[3] == 0x5f88 && v[4] == 0x591a && v[5] == wchar_cast(0x8bed) && v[6] == wchar_cast(0x8a00)); @@ -1097,7 +1097,7 @@ TEST(document_load_buffer_empty) CHECK(doc.load_buffer_inplace(buffer, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); CHECK(doc.load_buffer_inplace(0, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); - void* own_buffer = pugi::get_memory_allocation_function()(1); + void* own_buffer = get_memory_allocation_function()(1); CHECK(doc.load_buffer_inplace_own(own_buffer, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); CHECK(doc.load_buffer_inplace_own(0, 0, parse_default, encoding).status == status_no_document_element && !doc.first_child()); @@ -1133,7 +1133,7 @@ TEST(document_load_buffer_empty_fragment) CHECK(doc.load_buffer_inplace(buffer, 0, parse_fragment, encoding) && !doc.first_child()); CHECK(doc.load_buffer_inplace(0, 0, parse_fragment, encoding) && !doc.first_child()); - void* own_buffer = pugi::get_memory_allocation_function()(1); + void* own_buffer = get_memory_allocation_function()(1); CHECK(doc.load_buffer_inplace_own(own_buffer, 0, parse_fragment, encoding) && !doc.first_child()); CHECK(doc.load_buffer_inplace_own(0, 0, parse_fragment, encoding) && !doc.first_child()); @@ -1249,7 +1249,7 @@ TEST(document_load_exceptions) try { - pugi::xml_document doc; + xml_document doc; if (!doc.load_string(STR("