summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/test_document.cpp36
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));