summaryrefslogtreecommitdiff
path: root/src/xml/xml.test.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-02-04 12:41:32 -0600
committersanine <sanine.not@pm.me>2023-02-04 12:41:32 -0600
commitdb4aaea68f40f43e10ce73852630c94227001235 (patch)
treed8693709372cc8b9930c68f9fdd4abffc3f6c8d1 /src/xml/xml.test.c
parent059a70686c49d591fd7a193493745a7bc172cbca (diff)
add kai_tag_num_children()
Diffstat (limited to 'src/xml/xml.test.c')
-rw-r--r--src/xml/xml.test.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/xml/xml.test.c b/src/xml/xml.test.c
index d3b8360..58784be 100644
--- a/src/xml/xml.test.c
+++ b/src/xml/xml.test.c
@@ -71,5 +71,40 @@ LILY_TEST("duplicate xml attributes")
#include LILY_PUSH_TEST()
+LILY_TEST("count xml tag children")
+{
+ struct kai_tag_t *t = kai_parse_string(
+ "<no_kids />"
+ );
+ int child_count = kai_tag_num_children(t);
+ CHECK_EQ(child_count, 0, "%d");
+ kai_tag_destroy(t);
+
+ t = kai_parse_string(
+ "<one_child>"
+ " <child />"
+ "</one_child>"
+ );
+ child_count = kai_tag_num_children(t);
+ CHECK_EQ(child_count, 1, "%d");
+ kai_tag_destroy(t);
+
+ t = kai_parse_string(
+ "<six_kids>"
+ " <child />"
+ " <child />"
+ " <child />"
+ " <child />"
+ " <child />"
+ " <child />"
+ "</six_kids>"
+ );
+ child_count = kai_tag_num_children(t);
+ CHECK_EQ(child_count, 6, "%d");
+ kai_tag_destroy(t);
+}
+#include LILY_PUSH_TEST()
+
+
#define LILY_FILE_END
#include LILY_REGISTER_TESTS()