diff options
Diffstat (limited to 'src/geometry/geometry.test.c')
-rw-r--r-- | src/geometry/geometry.test.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c index 968060d..d918ffa 100644 --- a/src/geometry/geometry.test.c +++ b/src/geometry/geometry.test.c @@ -408,6 +408,77 @@ LILY_TEST("read vertices tag") #include LILY_PUSH_TEST() +LILY_TEST("fail to read non-triangles tag") +{ + struct kai_tag_t *t = kai_parse_string( + "<tag />" + ); + + struct ka_triangles_t triangles; + int result = kai_read_triangles(&triangles, t); + CHECK_EQ(result, -1, "%d"); + + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("fail to read triangles tag with no specified count") +{ + struct kai_tag_t *t = kai_parse_string( + "<triangles />" + ); + + struct ka_triangles_t triangles; + int result = kai_read_triangles(&triangles, t); + CHECK_EQ(result, -1, "%d"); + kai_tag_destroy(t); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("read triangles tag") +{ + struct kai_tag_t *t = kai_parse_string( + "<triangles count=\"2\" material=\"Bricks\">" + " <input semantic=\"VERTEX\" source=\"#verts\" offset=\"0\"/>" + " <input semantic=\"NORMAL\" source=\"#normal\" offset=\"1\"/>" + " <p>" + " 0 0 1 3 2 1" + " 0 0 2 1 3 2" + " </p>" + "</triangles>" + ); + + struct ka_triangles_t triangles; + int result = kai_read_triangles(&triangles, t); + kai_tag_destroy(t); + + REQUIRE_EQ(result, 0, "%d"); + CHECK_EQ(triangles.name, NULL, "%p"); + CHECK_EQ(triangles.count, 2, "%d"); + CHECK_EQS(triangles.material, "Bricks"); + CHECK_EQ(triangles.input_count, 2, "%d"); + CHECK_EQS(triangles.input[1].semantic, "NORMAL"); + CHECK_EQ(triangles.p_count, 12, "%d"); + CHECK_EQ(triangles.p[0], 0, "%d"); + CHECK_EQ(triangles.p[1], 0, "%d"); + CHECK_EQ(triangles.p[2], 1, "%d"); + CHECK_EQ(triangles.p[3], 3, "%d"); + CHECK_EQ(triangles.p[4], 2, "%d"); + CHECK_EQ(triangles.p[5], 1, "%d"); + + CHECK_EQ(triangles.p[6], 0, "%d"); + CHECK_EQ(triangles.p[7], 0, "%d"); + CHECK_EQ(triangles.p[8], 2, "%d"); + CHECK_EQ(triangles.p[9], 1, "%d"); + CHECK_EQ(triangles.p[10], 3, "%d"); + CHECK_EQ(triangles.p[11], 2, "%d"); + + kai_release_triangles(triangles); +} +#include LILY_PUSH_TEST() + #define LILY_FILE_END |