diff options
author | sanine <sanine.not@pm.me> | 2023-02-04 12:53:00 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-02-04 12:53:00 -0600 |
commit | ef5142f0d044b3480790606536c492719c6e73ef (patch) | |
tree | 8c7abad469ddfddeee5aabe537761a13a83d64ce /src/geometry/geometry.test.c | |
parent | db4aaea68f40f43e10ce73852630c94227001235 (diff) |
implement kai_read_accessor()
Diffstat (limited to 'src/geometry/geometry.test.c')
-rw-r--r-- | src/geometry/geometry.test.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c index dec16e9..2c172f2 100644 --- a/src/geometry/geometry.test.c +++ b/src/geometry/geometry.test.c @@ -117,5 +117,66 @@ LILY_TEST("read param tag") #include LILY_PUSH_TEST() +LILY_TEST("fail to read non-accessor tag") +{ + struct kai_tag_t *t = kai_parse_string( + "<tag />" + ); + + struct ka_accessor_t accessor; + int result = kai_read_accessor(&accessor, t); + CHECK_EQ(result, -1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("fail to read accessor tag with no specified count or source") +{ + struct kai_tag_t *t = kai_parse_string( + "<accessor />" + ); + + struct ka_accessor_t accessor; + int result = kai_read_accessor(&accessor, t); + CHECK_EQ(result, -1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("parse accessor") +{ + struct kai_tag_t *t = kai_parse_string( + "<accessor source=\"some id\" count=\"6\" stride=\"3\">" + " <param type=\"float\" name=\"x\" />" + " <param type=\"float\" name=\"y\" />" + " <param type=\"float\" name=\"z\" />" + "</accessor>" + ); + + struct ka_accessor_t acc; + int result = kai_read_accessor(&acc, t); + kai_tag_destroy(t); + + CHECK_EQ(result, 0, "%d"); + CHECK_EQ(acc.count, 6, "%d"); + CHECK_EQ(acc.offset, 0, "%d"); + CHECK_EQS(acc.source, "some id"); + CHECK_EQ(acc.stride, 3, "%d"); + + REQUIRE_EQ(acc.param_count, 3, "%d"); + CHECK_EQS(acc.param[0].name, "x"); + CHECK_EQS(acc.param[1].name, "y"); + CHECK_EQS(acc.param[2].name, "z"); + + free(acc.source); + for (int i=0; i<3; i++) free(acc.param[i].name); +} +#include LILY_PUSH_TEST() + + #define LILY_FILE_END #include LILY_REGISTER_TESTS() |