diff options
Diffstat (limited to 'libk/test/string.cc')
-rw-r--r-- | libk/test/string.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libk/test/string.cc b/libk/test/string.cc new file mode 100644 index 0000000..4d7d340 --- /dev/null +++ b/libk/test/string.cc @@ -0,0 +1,14 @@ +#include <string.h> + +// strlen +static_assert(strlen("") == 0); +static_assert(strlen("0") == 1); +static_assert(strlen("hello") == 5); +static_assert(strlen("world") == 5); + +// reverse +static_assert([]() { + char s[] = "xyz"; + reverse(s, strlen(s)); + return s[0] == 'z' && s[1] == 'y' && s[2] == 'x' && s[3] == '\0'; +}()); |