summaryrefslogtreecommitdiff
path: root/tests/test_document.cpp
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:26:06 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-08-29 15:26:06 +0000
commit7fab1bf757700449b9dead756989d08e3114182a (patch)
tree61d4425675af600e3cdbac6721e4404b127f575a /tests/test_document.cpp
parent049fa3906db2786943617bb1b0ce3225be9a772f (diff)
tests: Reduced allocation count
git-svn-id: http://pugixml.googlecode.com/svn/trunk@662 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'tests/test_document.cpp')
-rw-r--r--tests/test_document.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/test_document.cpp b/tests/test_document.cpp
index f693579..37ec021 100644
--- a/tests/test_document.cpp
+++ b/tests/test_document.cpp
@@ -742,22 +742,24 @@ TEST(document_progressive_truncation)
char* original_data;
size_t original_size;
- CHECK(load_file_in_memory("tests/data/utftest_utf8.xml", original_data, original_size));
+ CHECK(load_file_in_memory("tests/data/truncation.xml", original_data, original_size));
+
+ char* buffer = new char[original_size];
for (size_t i = 1; i < original_size; ++i)
{
- char* truncated_data = new char[i];
+ char* truncated_data = buffer + original_size - i;
+
memcpy(truncated_data, original_data, i);
xml_document doc;
- bool result = doc.load_buffer(truncated_data, i);
+ bool result = doc.load_buffer_inplace(truncated_data, i);
// some truncate locations are parseable - those that come after declaration, declaration + doctype, declaration + doctype + comment and eof
CHECK(((i - 21) < 3 || (i - 66) < 3 || (i - 95) < 3 || i >= 3325) ? result : !result);
-
- delete[] truncated_data;
}
+ delete[] buffer;
delete[] original_data;
}