From 1b4564c02380d10f7f8630d73441e7f9aa83c812 Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 3 Feb 2023 23:01:31 -0600 Subject: begin implementing kai_read_float_array() --- src/geometry/geometry.c | 12 ++++++++++++ src/geometry/geometry.h | 3 +++ src/geometry/geometry.test.c | 15 +++++++++++++++ 3 files changed, 30 insertions(+) (limited to 'src/geometry') diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c index ba1ca58..5e93c55 100644 --- a/src/geometry/geometry.c +++ b/src/geometry/geometry.c @@ -2,4 +2,16 @@ #include #include "util/util.h" +#include "xml/xml.h" #include "geometry.h" + + +int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src) +{ + if (strcmp(src->type, "float_array") != 0) { + /* incorrect tag type */ + return -1; + } + + return 0; +} diff --git a/src/geometry/geometry.h b/src/geometry/geometry.h index da089c1..1672ffa 100644 --- a/src/geometry/geometry.h +++ b/src/geometry/geometry.h @@ -2,5 +2,8 @@ #define KALMIA_GEOMETRY_H #include +#include "xml/xml.h" + +int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src); #endif diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c index fe4421e..b724ee7 100644 --- a/src/geometry/geometry.test.c +++ b/src/geometry/geometry.test.c @@ -8,5 +8,20 @@ LILY_FILE_BEGIN(geometry_suite) +LILY_TEST("fail to read non-float_array") +{ + struct kai_tag_t *t = kai_parse_string( + "" + ); + + struct ka_float_array_t arr; + int result = kai_read_float_array(&arr, t); + CHECK_EQF(result, -1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + #define LILY_FILE_END #include LILY_REGISTER_TESTS() -- cgit v1.2.1