diff options
author | sanine <sanine.not@pm.me> | 2023-01-04 19:12:53 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-01-04 19:12:53 -0600 |
commit | 1b62e92bcc18762a8e4a2e9e4dc322705bfb7eec (patch) | |
tree | c20a207b2add59dcbe38b5f6c5ad7ea4ae8a481f /src/util/util.test.c | |
parent | dcb7a5389717c33f7fcfa67f5e2048cacc55d820 (diff) |
add kai_text_to_longs()
Diffstat (limited to 'src/util/util.test.c')
-rw-r--r-- | src/util/util.test.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/util/util.test.c b/src/util/util.test.c index 26aa3d1..6288039 100644 --- a/src/util/util.test.c +++ b/src/util/util.test.c @@ -91,5 +91,42 @@ LILY_TEST("convert string to real array with fewer conversions than expected") #include LILY_PUSH_TEST() +LILY_TEST("convert string to int array") +{ + /* the lucas numbers 4 u math fans out there */ + const char *str = "2 1 3 4 7"; + long array[5]; + int conv = kai_text_to_longs(array, str, 5); + + CHECK_EQ(conv, 5, "%d"); + + CHECK_EQ(array[0], 2, "%d"); + CHECK_EQ(array[1], 1, "%d"); + CHECK_EQ(array[2], 3, "%d"); + CHECK_EQ(array[3], 4, "%d"); + CHECK_EQ(array[4], 7, "%d"); +} +#include LILY_PUSH_TEST() + + +LILY_TEST("convert string to int array with fewer conversions than expected") +{ + const char *str = "2 1"; + long array[5]; + int conv = kai_text_to_longs(array, str, 5); + + CHECK_EQ(conv, 2, "%d"); + + CHECK_EQ(array[0], 2, "%d"); + CHECK_EQ(array[1], 1, "%d"); + CHECK_EQ(array[2], 0, "%d"); + CHECK_EQ(array[3], 0, "%d"); + CHECK_EQ(array[4], 0, "%d"); +} +#include LILY_PUSH_TEST() + + + + #define LILY_FILE_END #include LILY_REGISTER_TESTS() |