diff options
author | sanine <sanine.not@pm.me> | 2023-01-08 22:35:38 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-01-08 22:35:38 -0600 |
commit | 38a71a0e8eb25418f6a0be23960a30de566dfb7c (patch) | |
tree | 554a7ed5bdb6900af7b1bcb42d1f3548eea9bb96 /src/geometry/geometry.test.c | |
parent | a18d004be2217bd59c34ba5a3600f72de70c9419 (diff) |
add kai_parse_float_array
Diffstat (limited to 'src/geometry/geometry.test.c')
-rw-r--r-- | src/geometry/geometry.test.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c new file mode 100644 index 0000000..bb06aeb --- /dev/null +++ b/src/geometry/geometry.test.c @@ -0,0 +1,42 @@ +#include <string.h> + +#include <kalmia.h> +#include <ezxml.h> +#include "geometry.h" +#include "test/test.h" + + +LILY_FILE_BEGIN(geometry_suite) + + +LILY_TEST("parse float array") +{ + char str[1024]; + strncpy( + str, + "<float_array id=\"sequence\" count=\"5\">\n" + " -0.5 -0.25 0 0.25 0.5\n" + "</float_array>", + 1024 + ); + + ezxml_t tag = ezxml_parse_str(str, strlen(str)+1); + + struct ka_float_array_t float_array; + kai_parse_float_array(&float_array, tag); + + CHECK_EQS(float_array.id, "sequence"); + REQUIRE_EQ(float_array.count, 5, "%ul"); + REQUIRE_NEQ(float_array.data, NULL, "%p"); + + CHECK_EQ(float_array.data[0], -0.50, "%f"); + CHECK_EQ(float_array.data[1], -0.25, "%f"); + CHECK_EQ(float_array.data[2], 0.00, "%f"); + CHECK_EQ(float_array.data[3], 0.25, "%f"); + CHECK_EQ(float_array.data[4], 0.50, "%f"); +} +#include LILY_PUSH_TEST() + + +#define LILY_FILE_END +#include LILY_REGISTER_TESTS() |