summaryrefslogtreecommitdiff
path: root/src/geometry/geometry.test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/geometry/geometry.test.c')
-rw-r--r--src/geometry/geometry.test.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c
index d918ffa..17be188 100644
--- a/src/geometry/geometry.test.c
+++ b/src/geometry/geometry.test.c
@@ -480,6 +480,64 @@ LILY_TEST("read triangles tag")
#include LILY_PUSH_TEST()
+LILY_TEST("fail to read non-mesh tag")
+{
+ struct kai_tag_t *t = kai_parse_string(
+ "<tag />"
+ );
+
+ struct ka_mesh_t mesh;
+ int result = kai_read_mesh(&mesh, t);
+ CHECK_EQ(result, -1, "%d");
+
+ kai_tag_destroy(t);
+}
+#include LILY_PUSH_TEST()
+
+
+LILY_TEST("read mesh tag")
+{
+ struct kai_tag_t *t = kai_parse_string(
+ "<mesh>"
+ " <source id=\"source\">"
+ " <float_array count=\"1\">0.0</float_array>"
+ " <technique_common>"
+ " <accessor count=\"1\" source=\"xxx\">"
+ " <param type=\"float\" />"
+ " </accessor>"
+ " </technique_common>"
+ " </source>"
+ " <vertices id=\"box-Vtx\">"
+ " <input semantic=\"POSITION\" source=\"#box-Pos\"/>"
+ " </vertices>"
+ " <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>"
+ "</mesh>"
+ );
+
+ struct ka_mesh_t mesh;
+ int result = kai_read_mesh(&mesh, t);
+ kai_tag_destroy(t);
+
+ REQUIRE_EQ(result, 0, "%d");
+
+ CHECK_EQ(mesh.source_count, 1, "%d");
+ CHECK_EQS(mesh.source[0].id, "source");
+ CHECK_EQS(mesh.vertices.id, "box-Vtx");
+ CHECK_EQ(mesh.triangles_count, 1, "%d");
+ CHECK_EQ(mesh.triangles[0].count, 2, "%d");
+
+ kai_release_mesh(mesh);
+}
+#include LILY_PUSH_TEST()
+
+
#define LILY_FILE_END
#include LILY_REGISTER_TESTS()