summaryrefslogtreecommitdiff
path: root/src/xml/xml.test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xml/xml.test.c')
-rw-r--r--src/xml/xml.test.c26
1 files changed, 26 insertions, 0 deletions
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(
+ "<tag attr1=\"10\" qq=\"12\"></tag>"
+ );
+
+ 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()