summaryrefslogtreecommitdiff
path: root/src/util/util.test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/util.test.c')
-rw-r--r--src/util/util.test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/util/util.test.c b/src/util/util.test.c
index 9f64085..26aa3d1 100644
--- a/src/util/util.test.c
+++ b/src/util/util.test.c
@@ -57,5 +57,39 @@ LILY_TEST("expand array 100 times")
#include LILY_PUSH_TEST()
+LILY_TEST("convert string to real array")
+{
+ const char *str = "0 0.5 1 1.5 2";
+ ka_real_t array[5];
+ int conv = kai_text_to_reals(array, str, 5);
+
+ CHECK_EQ(conv, 5, "%d");
+
+ CHECK_EQF(array[0], 0.0f, "%f");
+ CHECK_EQF(array[1], 0.5f, "%f");
+ CHECK_EQF(array[2], 1.0f, "%f");
+ CHECK_EQF(array[3], 1.5f, "%f");
+ CHECK_EQF(array[4], 2.0f, "%f");
+}
+#include LILY_PUSH_TEST()
+
+
+LILY_TEST("convert string to real array with fewer conversions than expected")
+{
+ const char *str = "0 0.5 1";
+ ka_real_t array[5];
+ int conv = kai_text_to_reals(array, str, 5);
+
+ CHECK_EQ(conv, 3, "%d");
+
+ CHECK_EQF(array[0], 0.0f, "%f");
+ CHECK_EQF(array[1], 0.5f, "%f");
+ CHECK_EQF(array[2], 1.0f, "%f");
+ CHECK_EQF(array[3], 0.0f, "%f");
+ CHECK_EQF(array[4], 0.0f, "%f");
+}
+#include LILY_PUSH_TEST()
+
+
#define LILY_FILE_END
#include LILY_REGISTER_TESTS()