From 837ced350c5123c21c32154f1f2dc483238f7629 Mon Sep 17 00:00:00 2001 From: mloy Date: Thu, 30 Oct 2014 14:30:05 +0100 Subject: load_buffer_impl always checks if buffer is valid pointer and size > 0 added some tests to force invalid buffer and size = 0 --- tests/test_parse.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/test_parse.cpp') diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp index c45b783..56ea049 100644 --- a/tests/test_parse.cpp +++ b/tests/test_parse.cpp @@ -865,6 +865,8 @@ TEST(parse_empty) xml_document doc; CHECK(doc.load(STR("")).status == status_no_document_element && !doc.first_child()); CHECK(doc.load(STR(""), parse_fragment) && !doc.first_child()); + CHECK(doc.load_buffer(NULL, 12).status == status_no_document_element); + CHECK(doc.load_buffer("foo", 0).status == status_no_document_element); } TEST(parse_out_of_memory) -- cgit v1.2.3 From 9749920c8204930f868fed7fcf38ea2cc2b5a2ec Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Thu, 5 Mar 2015 11:35:39 -0800 Subject: Refactor contents=0 behavior Also change the error code to status_io_error --- tests/test_parse.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/test_parse.cpp') diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp index 500e44c..131840c 100644 --- a/tests/test_parse.cpp +++ b/tests/test_parse.cpp @@ -872,14 +872,16 @@ TEST(parse_load_buffer_null) { xml_document doc; - CHECK(doc.load_buffer(0, 12).status == status_no_document_element && !doc.first_child()); + CHECK(doc.load_buffer(0, 12).status == status_io_error && !doc.first_child()); + CHECK(doc.load_buffer(0, 12, parse_fragment).status == status_io_error && !doc.first_child()); } TEST(parse_load_buffer_empty) { xml_document doc; - CHECK(doc.load_buffer("foo", 0).status == status_no_document_element); + CHECK(doc.load_buffer("foo", 0).status == status_no_document_element && !doc.first_child()); + CHECK(doc.load_buffer("foo", 0, parse_fragment) && !doc.first_child()); } TEST(parse_out_of_memory) -- cgit v1.2.3 From 12e137d12fe6e6492e669cfa6c333f4a8911b1b2 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Thu, 5 Mar 2015 11:46:34 -0800 Subject: tests: Move null buffer tests to test_document Remove size=0 test since a better test is already there. --- tests/test_parse.cpp | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'tests/test_parse.cpp') diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp index 131840c..1b1e807 100644 --- a/tests/test_parse.cpp +++ b/tests/test_parse.cpp @@ -868,22 +868,6 @@ TEST(parse_empty) CHECK(doc.load_string(STR(""), parse_fragment) && !doc.first_child()); } -TEST(parse_load_buffer_null) -{ - xml_document doc; - - CHECK(doc.load_buffer(0, 12).status == status_io_error && !doc.first_child()); - CHECK(doc.load_buffer(0, 12, parse_fragment).status == status_io_error && !doc.first_child()); -} - -TEST(parse_load_buffer_empty) -{ - xml_document doc; - - CHECK(doc.load_buffer("foo", 0).status == status_no_document_element && !doc.first_child()); - CHECK(doc.load_buffer("foo", 0, parse_fragment) && !doc.first_child()); -} - TEST(parse_out_of_memory) { test_runner::_memory_fail_threshold = 256; -- cgit v1.2.3