summaryrefslogtreecommitdiff
path: root/tests/test_document.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-06-15 07:17:26 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-06-15 07:23:49 -0700
commitc40fd364ce856405f86fcc67250d36480e3712b8 (patch)
tree187e0aec95c655e10555bec92320acf60c068290 /tests/test_document.cpp
parent0fbc043183e4723961d6caa99bf9bb77c5edfb83 (diff)
tests: Add tests for loading special files
New tests try to load a folder as an XML document, and a device. Both are intended to exercise some otherwise non-hittable error paths in load_file implementation.
Diffstat (limited to 'tests/test_document.cpp')
-rw-r--r--tests/test_document.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_document.cpp b/tests/test_document.cpp
index 9860737..c7ceb8f 100644
--- a/tests/test_document.cpp
+++ b/tests/test_document.cpp
@@ -383,6 +383,23 @@ TEST(document_load_file_wide_out_of_memory)
CHECK(result.status == status_out_of_memory || result.status == status_file_not_found);
}
+#if defined(__linux__) || defined(__APPLE__)
+TEST(document_load_file_special_folder)
+{
+ xml_document doc;
+ xml_parse_result result = doc.load_file(".");
+ // status_out_of_memory is somewhat counter-intuitive but on Linux ftell returns LONG_MAX for directories
+ CHECK(result.status == status_file_not_found || result.status == status_io_error || result.status == status_out_of_memory);
+}
+
+TEST(document_load_file_special_device)
+{
+ xml_document doc;
+ xml_parse_result result = doc.load_file("/dev/tty");
+ CHECK(result.status == status_file_not_found || result.status == status_io_error);
+}
+#endif
+
TEST_XML(document_save, "<node/>")
{
xml_writer_string writer;