diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-03-24 01:04:02 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-03-24 01:04:02 +0300 |
commit | 5d66c96a190a396a1535c89bed4e33c2a005fe8d (patch) | |
tree | 36a681d8cf226cf30f06b2764c008077d9655dc7 /src/tests/slice.c | |
download | roscha-5d66c96a190a396a1535c89bed4e33c2a005fe8d.tar.gz roscha-5d66c96a190a396a1535c89bed4e33c2a005fe8d.zip |
Initial commit
Basically it works, just needs some polishing and maybe a couple of
features that I could actually use.
Also probably better docs. Not sure if it will be of use to anybody
besides me.
Diffstat (limited to 'src/tests/slice.c')
-rw-r--r-- | src/tests/slice.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/slice.c b/src/tests/slice.c new file mode 100644 index 0000000..1f3875a --- /dev/null +++ b/src/tests/slice.c @@ -0,0 +1,41 @@ +#include "tests/tests.h" +#include "slice.h" + +#include <string.h> + +static void +test_slice_cmp(void) +{ + struct slice s1a = { + .str = "hello world", + .start = 6, + .end = 11, + }; + struct slice s1b = { + .str = "world", + .start = 0, + .end = 5, + }; + asserteq(slice_cmp(&s1a, &s1b), 0); +} + +static void +test_slice_string(void) +{ + struct slice slice = { + .str = "hello world", + .start = 6, + .end = 11, + }; + sds str = sdsempty(); + slice_string(&slice, str); + asserteq(strcmp("world", str), 0); +} + +int +main(void) +{ + INIT_TESTS(); + RUN_TEST(test_slice_cmp); + RUN_TEST(test_slice_string); +} |