From b183f50a84efc495b322370976b22bad486800f3 Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 3 Feb 2023 23:55:45 -0600 Subject: add kai_tag_attr_to_long --- src/xml/xml.test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/xml/xml.test.c') diff --git a/src/xml/xml.test.c b/src/xml/xml.test.c index acee4b4..11c85c9 100644 --- a/src/xml/xml.test.c +++ b/src/xml/xml.test.c @@ -30,5 +30,31 @@ LILY_TEST("get xml attributes") #include LILY_PUSH_TEST() +LILY_TEST("convert xml attribute to long") +{ + struct kai_tag_t *t = kai_parse_string( + "" + ); + + int n = kai_tag_attr_to_long(t, "attr1", 0, NULL); + CHECK_EQ(n, 10, "%d"); + + int m = kai_tag_attr_to_long(t, "attr2", 14, NULL); + CHECK_EQ(m, 14, "%d"); + + int flag = -1; + int qq = kai_tag_attr_to_long(t, "qq", 0, &flag); + CHECK_EQ(qq, 12, "%d"); + CHECK_EQ(flag, 0, "%d"); + + int k = kai_tag_attr_to_long(t, "dne", 22, &flag); + CHECK_EQ(k, 22, "%d"); + CHECK_EQ(flag, 1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + #define LILY_FILE_END #include LILY_REGISTER_TESTS() -- cgit v1.2.1