diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-06-16 17:08:00 -0700 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-06-16 17:08:00 -0700 |
commit | 86593c0999a6652be8e93556149cdbfdf410512b (patch) | |
tree | 3bf9883b3f39687c462f5fcd7d0ecceb5cabf665 /tests | |
parent | 3aa2b40354208fd4171f5e4b2ddddaeb6ec881fb (diff) |
tests: Add more stream coverage tests
Cover both char and wchar_t stream loading in a single run instead of
using pugi::char_t.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_document.cpp | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/tests/test_document.cpp b/tests/test_document.cpp index 81c9014..bb5ed63 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -237,15 +237,27 @@ TEST(document_load_stream_nonseekable_out_of_memory) CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); } +TEST(document_load_stream_wide_nonseekable_out_of_memory) +{ + wchar_t contents[] = L"<node />"; + char_array_buffer<wchar_t> buffer(contents, contents + sizeof(contents) / sizeof(contents[0])); + std::basic_istream<wchar_t> in(&buffer); + + test_runner::_memory_fail_threshold = 1; + + pugi::xml_document doc; + CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); +} + TEST(document_load_stream_nonseekable_out_of_memory_large) { - std::basic_string<pugi::char_t> str; - str += STR("<node>"); - for (int i = 0; i < 10000; ++i) str += STR("<node />"); - str += STR("</node>"); + std::basic_string<char> str; + str += "<node>"; + for (int i = 0; i < 10000; ++i) str += "<node />"; + str += "</node>"; - char_array_buffer<pugi::char_t> buffer(&str[0], &str[0] + str.length()); - std::basic_istream<pugi::char_t> in(&buffer); + char_array_buffer<char> buffer(&str[0], &str[0] + str.length()); + std::basic_istream<char> in(&buffer); test_runner::_memory_fail_threshold = 10000 * 8 * 3 / 2; @@ -253,13 +265,17 @@ TEST(document_load_stream_nonseekable_out_of_memory_large) CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); } -TEST(document_load_stream_wide_nonseekable_out_of_memory) +TEST(document_load_stream_wide_nonseekable_out_of_memory_large) { - wchar_t contents[] = L"<node />"; - char_array_buffer<wchar_t> buffer(contents, contents + sizeof(contents) / sizeof(contents[0])); + std::basic_string<wchar_t> str; + str += L"<node>"; + for (int i = 0; i < 10000; ++i) str += L"<node />"; + str += L"</node>"; + + char_array_buffer<wchar_t> buffer(&str[0], &str[0] + str.length()); std::basic_istream<wchar_t> in(&buffer); - test_runner::_memory_fail_threshold = 1; + test_runner::_memory_fail_threshold = 10000 * 8 * 3 / 2; pugi::xml_document doc; CHECK_ALLOC_FAIL(CHECK(doc.load(in).status == status_out_of_memory)); |