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.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/geometry/geometry.test.c b/src/geometry/geometry.test.c
new file mode 100644
index 0000000..f400540
--- /dev/null
+++ b/src/geometry/geometry.test.c
@@ -0,0 +1,49 @@
+#include <string.h>
+#include <math.h>
+#include <kalmia.h>
+#include "test/test.h"
+#include "geometry.h"
+
+
+void parse_float_array();
+
+
+void suite_geometry()
+{
+ lily_run_test(parse_float_array);
+}
+
+
+void parse_float_array()
+{
+ char str[1024];
+ strncpy(
+ str,
+ "<float_array id=\"box-Pos-array\" count=\"24\">\n"
+ " -0.5 0.5 0.5\n"
+ " 0.5 0.5 0.5\n"
+ " -0.5 -0.5 0.5\n"
+ " 0.5 -0.5 0.5\n"
+ " -0.5 0.5 -0.5\n"
+ " 0.5 0.5 -0.5\n"
+ " -0.5 -0.5 -0.5\n"
+ " 0.5 -0.5 -0.5\n"
+ "</float_array>\n",
+ 1024
+ );
+ ezxml_t tag = ezxml_parse_str(str, strlen(str));
+
+ ka_float_array_t *a = kai_parse_float_array(tag);
+ ezxml_free(tag);
+
+ lily_assert_not_null(a);
+ lily_assert_string_equal(a->id, "box-Pos-array");
+ lily_assert_int_equal(a->count, 24);
+
+ int i;
+ for (i=0; i<24; i++) {
+ lily_assert_float_equal(fabs(a->array[i]), 0.5, 1e-3);
+ }
+
+ kai_free_float_array(a);
+}