diff options
Diffstat (limited to 'tests/test_document.cpp')
-rw-r--r-- | tests/test_document.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_document.cpp b/tests/test_document.cpp index 34c00a5..f693579 100644 --- a/tests/test_document.cpp +++ b/tests/test_document.cpp @@ -760,3 +760,37 @@ TEST(document_progressive_truncation) delete[] original_data; } + +TEST(document_load_buffer_short) +{ + char* data = new char[4]; + memcpy(data, "abcd", 4); + + xml_document doc; + + CHECK(doc.load_buffer(data, 4)); + CHECK(doc.load_buffer(data + 1, 3)); + CHECK(doc.load_buffer(data + 2, 2)); + CHECK(doc.load_buffer(data + 3, 1)); + CHECK(doc.load_buffer(data + 4, 0)); + CHECK(doc.load_buffer(0, 0)); + + delete[] data; +} + +TEST(document_load_buffer_inplace_short) +{ + char* data = new char[4]; + memcpy(data, "abcd", 4); + + xml_document doc; + + CHECK(doc.load_buffer_inplace(data, 4)); + CHECK(doc.load_buffer_inplace(data + 1, 3)); + CHECK(doc.load_buffer_inplace(data + 2, 2)); + CHECK(doc.load_buffer_inplace(data + 3, 1)); + CHECK(doc.load_buffer_inplace(data + 4, 0)); + CHECK(doc.load_buffer_inplace(0, 0)); + + delete[] data; +} |