Tests: add test for strpbrk()

This commit is contained in:
apio 2022-10-22 18:09:43 +02:00
parent ea96c5f47b
commit 766b6d26c8
2 changed files with 26 additions and 0 deletions

View File

@ -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);

View File

@ -127,3 +127,27 @@ DEFINE_TEST(strrchr)
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();
}