#include "Test.h" #include DEFINE_TEST(strlen) { START_TEST(strlen); const char* str = "Hello, World!"; size_t len = strlen(str); EXPECT_EQ(len, 13); char null[] = {'\0'}; len = strlen(null); EXPECT_EQ(len, 0); TEST_SUCCESS(); } DEFINE_TEST(strnlen) { START_TEST(strnlen); const char* str = "What is going on?"; size_t len = strnlen(str, 20); EXPECT_EQ(len, 17); len = strnlen(str, 15); EXPECT_EQ(len, 15); char buf[] = {'H', 'e', 'l', 'l', 'o'}; len = strnlen(buf, sizeof(buf)); EXPECT_EQ(len, sizeof(buf)); TEST_SUCCESS(); } DEFINE_TEST(strcspn) { START_TEST(strcspn); const char* str = "This string has vowels"; const char* vowels = "aeiou"; size_t len = strcspn(str, vowels); EXPECT_EQ(len, 2); str = "WWWWW"; len = strcspn(str, vowels); EXPECT_EQ(len, 5); TEST_SUCCESS(); }