diff --git a/tests/libc/Test.c b/tests/libc/Test.c index 5019ecf8..ae79c7cf 100644 --- a/tests/libc/Test.c +++ b/tests/libc/Test.c @@ -6,6 +6,7 @@ DEFINE_TEST(strcspn); DEFINE_TEST(strspn); DEFINE_TEST(strchr); DEFINE_TEST(strrchr); +DEFINE_TEST(strpbrk); DEFINE_TEST(atoi); DEFINE_TEST(atol); @@ -23,6 +24,7 @@ int main() RUN_TEST(strspn); RUN_TEST(strchr); RUN_TEST(strrchr); + RUN_TEST(strpbrk); START_TEST_CASE(stdlib.h); RUN_TEST(atoi); diff --git a/tests/libc/string.c b/tests/libc/string.c index b6e52258..f885e5b1 100644 --- a/tests/libc/string.c +++ b/tests/libc/string.c @@ -125,5 +125,29 @@ DEFINE_TEST(strrchr) EXPECT_EQ(ptr, str + 12); + TEST_SUCCESS(); +} + +DEFINE_TEST(strpbrk) +{ + START_TEST(strpbrk); + + const char* str = "Hello, world!"; + const char* vowels = "aeiou"; + + char* ptr = strpbrk(str, vowels); + + EXPECT_EQ(ptr, str + 1); + + str = "There are more vowels"; + ptr = strpbrk(str, vowels); + + EXPECT_EQ(ptr, str + 2); + + str = "zzzzzz"; + ptr = strpbrk(str, vowels); + + EXPECT_EQ(ptr, NULL); + TEST_SUCCESS(); } \ No newline at end of file