summaryrefslogtreecommitdiff
path: root/tests/test_parse.cpp
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-07-14 23:04:17 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2016-07-14 23:04:17 -0700
commit525b2fe5c3c304cbc2bec030b04539ab193e5dcd (patch)
tree94aac6c6029f3222cd26caf5e570e5cbddc6defa /tests/test_parse.cpp
parent70d7c7904e63f71e5f1b8960df6dc0a3c9087ff2 (diff)
tests: Add tests for latin1 detection
Diffstat (limited to 'tests/test_parse.cpp')
-rw-r--r--tests/test_parse.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_parse.cpp b/tests/test_parse.cpp
index dc709a2..62fbbce 100644
--- a/tests/test_parse.cpp
+++ b/tests/test_parse.cpp
@@ -1182,3 +1182,27 @@ TEST(parse_embed_pcdata)
CHECK_NODE_EX(doc, STR("<node>\n\t<key>value</key>\n\t<child>\n\t\t<inner1>value1</inner1>\n\t\t<inner2>value2</inner2>outer</child>\n\t<two>text<data />\n\t</two>\n</node>\n"), STR("\t"), format_indent);
}
}
+
+TEST(parse_encoding_detect)
+{
+ char test[] = "<?xml version='1.0' encoding='utf-8'?><n/>";
+
+ xml_document doc;
+ CHECK(doc.load_buffer(test, sizeof(test)));
+}
+
+TEST(parse_encoding_detect_latin1)
+{
+ char test0[] = "<?xml version='1.0' encoding='utf-8'?><n/>";
+ char test1[] = "<?xml version='1.0' encoding='iso-8859-1'?><n/>";
+ char test2[] = "<?xml version='1.0' encoding = \"latin1\"?><n/>";
+ char test3[] = "<?xml version='1.0' encoding='ISO-8859-1'?><n/>";
+ char test4[] = "<?xml version='1.0' encoding = \"LATIN1\"?><n/>";
+
+ xml_document doc;
+ CHECK(doc.load_buffer(test0, sizeof(test0)).encoding == encoding_utf8);
+ CHECK(doc.load_buffer(test1, sizeof(test1)).encoding == encoding_latin1);
+ CHECK(doc.load_buffer(test2, sizeof(test2)).encoding == encoding_latin1);
+ CHECK(doc.load_buffer(test3, sizeof(test3)).encoding == encoding_latin1);
+ CHECK(doc.load_buffer(test4, sizeof(test4)).encoding == encoding_latin1);
+} \ No newline at end of file