diff --git a/libc-test/src/functionalext/supplement/ctype/isalpha.c b/libc-test/src/functionalext/supplement/ctype/isalpha.c index 5f17e99f1d71de791e6d306b49ffd9e8a34becad..74043fecfc918d6cede5f45288437c051cda88ff 100644 --- a/libc-test/src/functionalext/supplement/ctype/isalpha.c +++ b/libc-test/src/functionalext/supplement/ctype/isalpha.c @@ -79,6 +79,47 @@ void isalpha_0500(void) EXPECT_EQ("isalpha_0500", total, 52); } +/** + * @tc.name : isalpha_0600 + * @tc.desc : Verify all the letters in the ASCII code table + * @tc.level : Level 1 + */ +void isalpha_0600(void) +{ + for (int i = 65; i < 91; i++) { + int ret = isalpha((char)i); + EXPECT_NE("isalpha_0600", ret, COUNT_ZERO); + } + + for (int i = 97; i < 123; i++) { + int ret = isalpha((char)i); + EXPECT_NE("isalpha_0600", ret, COUNT_ZERO); + } +} + +/** + * @tc.name : isalpha_0700 + * @tc.desc : Verify all non-alphabetic characters in the ASCII code table + * @tc.level : Level 1 + */ +void isalpha_0700(void) +{ + for (int i = 0; i < 65; i++) { + int ret = isalpha((char)i); + EXPECT_EQ("isalpha_0700", ret, COUNT_ZERO); + } + + for (int i = 91; i < 97; i++) { + int ret = isalpha((char)i); + EXPECT_EQ("isalpha_0700", ret, COUNT_ZERO); + } + + for (int i = 123; i < 128; i++) { + int ret = isalpha((char)i); + EXPECT_EQ("isalpha_0700", ret, COUNT_ZERO); + } +} + int main(void) { isalpha_0100(); @@ -86,5 +127,7 @@ int main(void) isalpha_0300(); isalpha_0400(); isalpha_0500(); + isalpha_0600(); + isalpha_0700(); return t_status; } \ No newline at end of file diff --git a/libc-test/src/functionalext/supplement/ctype/isascii.c b/libc-test/src/functionalext/supplement/ctype/isascii.c index d918ac00856ceaf7b40d145758a9d580262c3d89..5ae8c4571742d1f29dd052f88ece4b8bf87f74f9 100755 --- a/libc-test/src/functionalext/supplement/ctype/isascii.c +++ b/libc-test/src/functionalext/supplement/ctype/isascii.c @@ -37,8 +37,22 @@ void isascii_0100(void) } } +/** + * @tc.name : isascii_0200 + * @tc.desc : Test all ASCII code characters + * @tc.level : Level 1 + */ +void isascii_0200(void) +{ + for (int i = 0; i < 128; i++) { + int ret = isascii((char)i); + EXPECT_EQ("isascii_0200", ret, ONREXPECT); + } +} + int main(void) { isascii_0100(); + isascii_0200(); return t_status; } \ No newline at end of file diff --git a/libc-test/src/functionalext/supplement/ctype/tolower.c b/libc-test/src/functionalext/supplement/ctype/tolower.c index ee77d943cc9b24660886fbbda69ea744f7854a2c..2594eb80e7acfd7cdf84f31530c71a4a83cb7415 100644 --- a/libc-test/src/functionalext/supplement/ctype/tolower.c +++ b/libc-test/src/functionalext/supplement/ctype/tolower.c @@ -14,6 +14,7 @@ */ #include +#include #include #include "test.h" @@ -73,11 +74,89 @@ void tolower_0400(void) } } +/** + * @tc.name : tolower_0500 + * @tc.desc : Test the result of passing whitespace character into tolower + * @tc.level : Level 2 + */ +void tolower_0500(void) +{ + char ch = ' '; + char result = tolower(ch); + if (result != ch) { + t_error("%s tolower get result is %c but want get value %c ", __func__, result, ch); + } +} + +/** + * @tc.name : tolower_0600 + * @tc.desc : Test the result of passing all lowercase characters into tolower + * @tc.level : Level 2 + */ +void tolower_0600(void) +{ + char str1[] = "helloworld"; + size_t sizeStr = sizeof(str1); + char str2[sizeStr]; + for (int i = 0; str1[i]; i++) { + str2[i] = tolower(str1[i]); + } + char wantStr[] = "helloworld"; + int result = strcmp(wantStr, str2); + if (result != 0) { + t_error("%s tolower get str2 is %s but want get value %s ", __func__, str2, wantStr); + } +} + +/** + * @tc.name : tolower_0700 + * @tc.desc : Test the result of passing all uppercase characters into tolower + * @tc.level : Level 2 + */ +void tolower_0700(void) +{ + char str1[] = "HELLOWORLD"; + size_t sizeStr = sizeof(str1); + char str2[sizeStr]; + for (int i = 0; str1[i]; i++) { + str2[i] = tolower(str1[i]); + } + char wantStr[] = "helloworld"; + int result = strcmp(wantStr, str2); + if (result != 0) { + t_error("%s tolower get str2 is %s but want get value %s ", __func__, str2, wantStr); + } +} + +/** + * @tc.name : tolower_0800 + * @tc.desc : Test the result of passing Uncertain characters into tolower + * @tc.level : Level 2 + */ +void tolower_0800(void) +{ + char str1[] = "Hello world!"; + size_t sizeStr = sizeof(str1); + char str2[sizeStr]; + for (int i = 0; str1[i]; i++) { + str2[i] = tolower(str1[i]); + } + char wantStr[] = "hello world!"; + int result = strcmp(wantStr, str2); + if (result != 0) { + t_error("%s tolower get str2 is %s but want get value %s ", __func__, str2, wantStr); + } +} + int main(int argc, char *argv[]) { tolower_0100(); tolower_0200(); tolower_0300(); tolower_0400(); + tolower_0500(); + tolower_0600(); + tolower_0700(); + tolower_0800(); return t_status; } \ No newline at end of file diff --git a/libc-test/src/functionalext/supplement/ctype/toupper.c b/libc-test/src/functionalext/supplement/ctype/toupper.c index 55608807819b633c2d6303688f8e721c78435ea5..72638da4634d25191103e8465bf2634ab4594c31 100644 --- a/libc-test/src/functionalext/supplement/ctype/toupper.c +++ b/libc-test/src/functionalext/supplement/ctype/toupper.c @@ -14,6 +14,7 @@ */ #include +#include #include #include "test.h" @@ -73,11 +74,89 @@ void toupper_0400(void) } } +/** + * @tc.name : toupper_0500 + * @tc.desc : Test the result of passing whitespace character into toupper + * @tc.level : Level 2 + */ +void toupper_0500(void) +{ + char ch = ' '; + char result = toupper(ch); + if (result != ch) { + t_error("%s toupper get result is %c but want get value %c ", __func__, result, ch); + } +} + +/** + * @tc.name : toupper_0600 + * @tc.desc : Test the result of passing all lowercase characters into toupper + * @tc.level : Level 2 + */ +void toupper_0600(void) +{ + char str1[] = "helloworld"; + size_t sizeStr = sizeof(str1); + char str2[sizeStr]; + for (int i = 0; str1[i]; i++) { + str2[i] = toupper(str1[i]); + } + char wantStr[] = "HELLOWORLD"; + int result = strcmp(wantStr, str2); + if (result != 0) { + t_error("%s toupper get str2 is %s but want get value %s ", __func__, str2, wantStr); + } +} + +/** + * @tc.name : toupper_0700 + * @tc.desc : Test the result of passing all uppercase characters into toupper + * @tc.level : Level 2 + */ +void toupper_0700(void) +{ + char str1[] = "HELLOWORLD"; + size_t sizeStr = sizeof(str1); + char str2[sizeStr]; + for (int i = 0; str1[i]; i++) { + str2[i] = toupper(str1[i]); + } + char wantStr[] = "HELLOWORLD"; + int result = strcmp(wantStr, str2); + if (result != 0) { + t_error("%s toupper get str2 is %s but want get value %s ", __func__, str2, wantStr); + } +} + +/** + * @tc.name : toupper_0800 + * @tc.desc : Test the result of passing Uncertain characters into toupper + * @tc.level : Level 2 + */ +void toupper_0800(void) +{ + char str1[] = "Hello world!"; + size_t sizeStr = sizeof(str1); + char str2[sizeStr]; + for (int i = 0; str1[i]; i++) { + str2[i] = toupper(str1[i]); + } + char wantStr[] = "HELLO WORLD!"; + int result = strcmp(wantStr, str2); + if (result != 0) { + t_error("%s toupper get str2 is %s but want get value %s ", __func__, str2, wantStr); + } +} + int main(int argc, char *argv[]) { toupper_0100(); toupper_0200(); toupper_0300(); toupper_0400(); + toupper_0500(); + toupper_0600(); + toupper_0700(); + toupper_0800(); return t_status; } \ No newline at end of file