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/geometry/geometry.c | 6 ++++++ src/geometry/geometry.test.c | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/geometry') diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c index 5e93c55..322ada0 100644 --- a/src/geometry/geometry.c +++ b/src/geometry/geometry.c @@ -13,5 +13,11 @@ int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src) return -1; } + char *count_str = kai_tag_get_attr(src, "count"); + if (count_str == NULL) { + /* missing required count attribute! */ + return -1; + } + return 0; } diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c index b724ee7..d433066 100644 --- a/src/geometry/geometry.test.c +++ b/src/geometry/geometry.test.c @@ -16,7 +16,24 @@ LILY_TEST("fail to read non-float_array") struct ka_float_array_t arr; int result = kai_read_float_array(&arr, t); - CHECK_EQF(result, -1, "%d"); + CHECK_EQ(result, -1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("fail to read float_array without count attribute") +{ + struct kai_tag_t *t = kai_parse_string( + "" + " blah blah internals" + "" + ); + + struct ka_float_array_t arr; + int result = kai_read_float_array(&arr, t); + CHECK_EQ(result, -1, "%d"); kai_tag_destroy(t); } -- cgit v1.2.1