#include #include #include "geometry.h" #include "test/test.h" 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_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); } #include LILY_PUSH_TEST() LILY_TEST("read normal float_array") { struct kai_tag_t *t = kai_parse_string( "" " -0.5 0.0 0.5" "" ); struct ka_float_array_t arr; int result = kai_read_float_array(&arr, t); REQUIRE_EQ(result, 0, "%d"); kai_tag_destroy(t); REQUIRE_EQ(arr.count, 3, "%d"); CHECK_EQS(arr.id, "arr"); CHECK_EQ(arr.digits, 6, "%d"); CHECK_EQ(arr.magnitude, 38, "%d"); CHECK_EQF(arr.buf[0], -0.5, "%f"); CHECK_EQF(arr.buf[1], 0.0, "%f"); CHECK_EQF(arr.buf[2], 0.5, "%f"); free(arr.id); free(arr.buf); } #include LILY_PUSH_TEST() LILY_TEST("fail to read non-param tag") { struct kai_tag_t *t = kai_parse_string( "" ); struct ka_param_t param; int result = kai_read_param(¶m, t); CHECK_EQ(result, -1, "%d"); kai_tag_destroy(t); } #include LILY_PUSH_TEST() LILY_TEST("fail to read param tag with no specified type") { struct kai_tag_t *t = kai_parse_string( "" ); struct ka_param_t param; int result = kai_read_param(¶m, t); CHECK_EQ(result, -1, "%d"); kai_tag_destroy(t); } #include LILY_PUSH_TEST() LILY_TEST("read param tag") { struct kai_tag_t *t = kai_parse_string( "" ); struct ka_param_t param; int result = kai_read_param(¶m, t); kai_tag_destroy(t); REQUIRE_EQ(result, 0, "%d"); CHECK_EQS(param.name, "x"); CHECK_EQ(param.sid, NULL, "%p"); CHECK_EQS(param.type, "float"); CHECK_EQ(param.semantic, NULL, "%p"); } #include LILY_PUSH_TEST() #define LILY_FILE_END #include LILY_REGISTER_TESTS()