summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-06-14 23:50:21 -0700
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-06-14 23:50:21 -0700
commit0fbc043183e4723961d6caa99bf9bb77c5edfb83 (patch)
tree49f0ba1834888d2d2dcc8d1e73b8fc9d50b1840b
parent52da6f71d0927d69a42ee3776bc1495cd4bf90b6 (diff)
tests: Increase compact_pointer coverage
This adds tests that complete branch coverage in compact pointer encoding/decoding code (previously first_attribute was always encoded using compact encoding in the entire test suite).
-rw-r--r--tests/test_compact.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_compact.cpp b/tests/test_compact.cpp
index f9560c9..f5dc4ee 100644
--- a/tests/test_compact.cpp
+++ b/tests/test_compact.cpp
@@ -111,4 +111,38 @@ TEST_XML(compact_out_of_memory_remove, "<n a='v'/>")
CHECK_ALLOC_FAIL(CHECK(!n.remove_attribute(a)));
CHECK_ALLOC_FAIL(CHECK(!doc.remove_child(n)));
}
+
+TEST_XML(compact_pointer_attribute_list, "<n a='v'/>")
+{
+ xml_node n = doc.child(STR("n"));
+ xml_attribute a = n.attribute(STR("a"));
+
+ // make sure we fill the page with node x
+ for (int i = 0; i < 1000; ++i)
+ doc.append_child(STR("x"));
+
+ // this requires extended encoding for prev_attribute_c/next_attribute
+ n.append_attribute(STR("b"));
+
+ // this requires extended encoding for first_attribute
+ n.remove_attribute(a);
+
+ CHECK(!n.attribute(STR("a")));
+ CHECK(n.attribute(STR("b")));
+}
+
+TEST_XML(compact_pointer_node_list, "<n/>")
+{
+ xml_node n = doc.child(STR("n"));
+
+ // make sure we fill the page with node x
+ // this requires extended encoding for prev_sibling_c/next_sibling
+ for (int i = 0; i < 1000; ++i)
+ doc.append_child(STR("x"));
+
+ // this requires extended encoding for first_child
+ n.append_child(STR("child"));
+
+ CHECK(n.child(STR("child")));
+}
#endif