#include "tests/tests.h" #include "slice.h" #include 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_sprint(void) { struct slice slice = { .str = "hello world", .start = 6, .end = 11, }; char buf[32]; slice_sprint(&slice, buf); asserteq(strcmp("world", buf), 0); } int main(void) { INIT_TESTS(); RUN_TEST(test_slice_cmp); RUN_TEST(test_slice_sprint); }