Luna/tests/libc/TestString.cpp

25 lines
459 B
C++
Raw Normal View History

#include <string.h>
#include <test.h>
TestResult test_strstr()
{
const char* find = "Hello, world!";
validate(strstr(find, "Hello") == find);
validate(strstr(find, "!") == find + 12);
validate(strstr(find, "world") == find + 7);
validate(strstr(find, "Hullo") == nullptr);
validate(strstr(find, "notfound") == nullptr);
test_success;
}
Result<void> test_main()
{
test_prelude;
run_test(test_strstr);
return {};
}