From 8d39e54f4915de0d12f1bfa254d86639b0e317de Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Mon, 9 Aug 2010 11:24:26 +0000 Subject: tests: Added tests for short buffers (they duplicate the progressive truncation test, but it's better to have explicit tests) git-svn-id: http://pugixml.googlecode.com/svn/trunk@632 99668b35-9821-0410-8761-19e4c4f06640 --- tests/test_document.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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; +} -- cgit v1.2.3