summaryrefslogtreecommitdiff
path: root/src/transform.test.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-11-27 01:19:14 -0600
committersanine <sanine.not@pm.me>2022-11-27 01:19:14 -0600
commit6053d87cd02cd5aec9da5bc46039ec4cca181dec (patch)
tree81dd8f2fd0fc5bef5951bee324a8ceb0bf419613 /src/transform.test.c
parentc42d9264aed8da3a057719cab7390fa55904bda6 (diff)
add scale parsing
Diffstat (limited to 'src/transform.test.c')
-rw-r--r--src/transform.test.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/transform.test.c b/src/transform.test.c
index f0cd06f..ba663bb 100644
--- a/src/transform.test.c
+++ b/src/transform.test.c
@@ -10,6 +10,9 @@ void parse_identity();
void parse_rotate_fail();
void parse_rotate();
+void parse_scale_fail();
+void parse_scale();
+
void parse_translate_fail();
void parse_translate();
@@ -20,6 +23,8 @@ void suite_transform()
lily_run_test(parse_identity);
lily_run_test(parse_rotate_fail);
lily_run_test(parse_rotate);
+ lily_run_test(parse_scale_fail);
+ lily_run_test(parse_scale);
lily_run_test(parse_translate_fail);
lily_run_test(parse_translate);
}
@@ -134,6 +139,58 @@ void parse_rotate()
}
+/* ======== scale ======== */
+void parse_scale_fail()
+{
+ char str[128];
+ strncpy(str, "<non></non>", 128);
+ ezxml_t tag = ezxml_parse_str(str, strlen(str));
+
+ ka_matrix_t mat;
+ int rc = kai_parse_scale(&mat, tag);
+ lily_assert_true(rc != 0);
+
+ ezxml_free(tag);
+}
+
+
+void parse_scale()
+{
+ char str[512];
+ strncpy(
+ str,
+ "<scale>\n"
+ " 10 5 -1\n"
+ "</scale>",
+ 512
+ );
+ ezxml_t tag = ezxml_parse_str(str, strlen(str));
+
+ ka_matrix_t mat;
+ mat[0] = 100;
+ int rc = kai_parse_scale(&mat, tag);
+ lily_assert_true(rc == 0);
+ ezxml_free(tag);
+
+ lily_assert_float_equal(mat[0], 10.0f, 1e-3);
+ lily_assert_float_equal(mat[1], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[2], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[3], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[4], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[5], 5.0f, 1e-3);
+ lily_assert_float_equal(mat[6], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[7], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[8], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[9], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[10],-1.0f, 1e-3);
+ lily_assert_float_equal(mat[11], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[12], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[13], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[14], 0.0f, 1e-3);
+ lily_assert_float_equal(mat[15], 1.0f, 1e-3);
+}
+
+
/* ======== translate ======== */
void parse_translate_fail()
{