|
@@ -139,6 +139,35 @@ test_strcpy (void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+test_stpcpy (void)
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ it = "stpcpy";
|
|
|
+ check (stpcpy (one, "abcd") == one+4, 1);
|
|
|
+ equal (one, "abcd", 2);
|
|
|
+
|
|
|
+ (void) stpcpy (one, "x");
|
|
|
+ equal (one, "x", 3);
|
|
|
+ equal (one+2, "cd", 4);
|
|
|
+
|
|
|
+ (void) stpcpy (two, "hi there");
|
|
|
+ (void) stpcpy (one, two);
|
|
|
+ equal (one, "hi there", 5);
|
|
|
+ equal (two, "hi there", 6);
|
|
|
+
|
|
|
+ (void) stpcpy (one, "");
|
|
|
+ equal (one, "", 7);
|
|
|
+
|
|
|
+ for (i = 0; i < 16; i++)
|
|
|
+ {
|
|
|
+ (void) stpcpy (one + i, "hi there");
|
|
|
+ equal (one + i, "hi there", 8 + (i * 2));
|
|
|
+ (void) stpcpy (two, one + i);
|
|
|
+ equal (two, "hi there", 9 + (i * 2));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void
|
|
|
test_strcat (void)
|
|
|
{
|
|
@@ -442,6 +471,33 @@ test_strstr (void)
|
|
|
check(strstr(one, "bbca") == one+1, 16);
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+test_strcasestr (void)
|
|
|
+{
|
|
|
+ it = "strcasestr";
|
|
|
+ check(strcasestr("abcd", "z") == NULL, 1);
|
|
|
+ check(strcasestr("abcd", "abx") == NULL, 2);
|
|
|
+ (void) strcpy(one, "aBcD");
|
|
|
+ check(strcasestr(one, "c") == one+2, 3);
|
|
|
+ check(strcasestr(one, "bc") == one+1, 4);
|
|
|
+ check(strcasestr(one, "d") == one+3, 5);
|
|
|
+ check(strcasestr(one, "cd") == one+2, 6);
|
|
|
+ check(strcasestr(one, "abc") == one, 7);
|
|
|
+ check(strcasestr(one, "abcd") == one, 8);
|
|
|
+ check(strcasestr(one, "abcde") == NULL, 9);
|
|
|
+ check(strcasestr(one, "de") == NULL, 10);
|
|
|
+ check(strcasestr(one, "") == one, 11);
|
|
|
+ (void) strcpy(one, "aBaBa");
|
|
|
+ check(strcasestr(one, "ba") == one+1, 12);
|
|
|
+ (void) strcpy(one, "");
|
|
|
+ check(strcasestr(one, "b") == NULL, 13);
|
|
|
+ check(strcasestr(one, "") == one, 14);
|
|
|
+ (void) strcpy(one, "BcBcA");
|
|
|
+ check(strcasestr(one, "bca") == one+2, 15);
|
|
|
+ (void) strcpy(one, "BbBcABBcA");
|
|
|
+ check(strcasestr(one, "bbca") == one+1, 16);
|
|
|
+}
|
|
|
+
|
|
|
void
|
|
|
test_strspn (void)
|
|
|
{
|
|
@@ -913,6 +969,9 @@ main (void)
|
|
|
|
|
|
test_strcpy ();
|
|
|
|
|
|
+
|
|
|
+ test_stpcpy ();
|
|
|
+
|
|
|
|
|
|
test_strcat ();
|
|
|
|
|
@@ -945,6 +1004,7 @@ main (void)
|
|
|
|
|
|
|
|
|
test_strstr ();
|
|
|
+ test_strcasestr ();
|
|
|
|
|
|
|
|
|
test_strspn ();
|