summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-09 11:24:26 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-09 11:24:26 +0000
commit8d39e54f4915de0d12f1bfa254d86639b0e317de (patch)
treefb90022099083c8ea11a6caa0149195a72f95b82
parent241b998fa3755059584e182bcfb479e0abf76615 (diff)
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
-rw-r--r--tests/test_document.cpp34
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;
+}