From db4aaea68f40f43e10ce73852630c94227001235 Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 4 Feb 2023 12:41:32 -0600 Subject: add kai_tag_num_children() --- src/xml/xml.test.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/xml/xml.test.c') 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( + "" + ); + int child_count = kai_tag_num_children(t); + CHECK_EQ(child_count, 0, "%d"); + kai_tag_destroy(t); + + t = kai_parse_string( + "" + " " + "" + ); + child_count = kai_tag_num_children(t); + CHECK_EQ(child_count, 1, "%d"); + kai_tag_destroy(t); + + t = kai_parse_string( + "" + " " + " " + " " + " " + " " + " " + "" + ); + 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() -- cgit v1.2.1