aboutsummaryrefslogtreecommitdiff
path: root/string/tester.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-03-13 17:02:23 +0000
committerUlrich Drepper <drepper@redhat.com>1998-03-13 17:02:23 +0000
commit14c44e2ec42a3c973e268add83a11e3e5fb0b80c (patch)
tree9b5d83d08dc977b0e6c97b7e977b591ef7bd47f3 /string/tester.c
parenta7b591dc310c675cb325db9850f10c2e2fe1aba7 (diff)
downloadglibc-14c44e2ec42a3c973e268add83a11e3e5fb0b80c.zip
glibc-14c44e2ec42a3c973e268add83a11e3e5fb0b80c.tar.gz
glibc-14c44e2ec42a3c973e268add83a11e3e5fb0b80c.tar.bz2
Update.
1998-03-13 16:55 Ulrich Drepper <drepper@cygnus.com> * string/tester.c (test_strpbrk): Add more strpbrk tests. (test_strsep): Likewise. Correct horrible bugs. * string/bits/string2.h (strcspn): Optimize also reject string of length 2 and 3. (strspn): Likewise. (strpbrk): Likewise. (strsep): Likewise. Correct bug with successive separators and separators at the end of the string. * sysdeps/generic/strsep.c: Correct bug with successive separators and separators at the end of the string. 1998-03-13 13:11 Tim Waugh <tim@cyberelk.demon.co.uk> * posix/wordexp.c (parse_param): Positional parameters ($1, $2 etc) now handled, as well as $$ (pid). * posix/Makefile (tests): Execute wordexp-test.sh for `make check'. (distribute): Add wordexp-tst.sh. * posix/wordexp-tst.sh: New file. * posix/wordexp.c (parse_param): $# (or ${#}) expands to the number of positional parameters. Renamed substitute_length to seen_hash. Don't free(env) is env is NULL. 1998-03-13 16:50 Ulrich Drepper <drepper@cygnus.com> * libc.map: Add pthread_attr_init to GLIBC_2.1. 1998-03-13 15:01 Ulrich Drepper <drepper@cygnus.com> * gmon/gmon.c: Allow GMON_OUT_PREFIX variable to specify filename for output file replacing gmon.out. Patch by Dean Gaudet <dgaudet@arctic.org>. 1998-03-12 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/dl-misc.c (_dl_debug_message): Fix printing of pid. Clean up namespace. Optimize finding end of line. 1998-03-12 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/rtld.c (process_envvars): Ignore LD_DEBUG_OUTPUT if running securely. Optimized. (process_dl_debug): Add ':' to list of separators. Optimized. 1998-03-13 10:25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Diffstat (limited to 'string/tester.c')
-rw-r--r--string/tester.c117
1 files changed, 76 insertions, 41 deletions
diff --git a/string/tester.c b/string/tester.c
index d74ab72..9545c28 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -1,5 +1,5 @@
/* Tester for string functions.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -479,7 +479,16 @@ test_strpbrk (void)
check(strpbrk(one, "db") == one+1, 9); /* Another variant. */
(void) strcpy(one, "");
check(strpbrk(one, "bc") == NULL, 10); /* Empty string. */
- check(strpbrk(one, "") == NULL, 11); /* Both strings empty. */
+ (void) strcpy(one, "");
+ check(strpbrk(one, "bcd") == NULL, 11); /* Empty string. */
+ (void) strcpy(one, "");
+ check(strpbrk(one, "bcde") == NULL, 12); /* Empty string. */
+ check(strpbrk(one, "") == NULL, 13); /* Both strings empty. */
+ (void) strcpy(one, "abcabdea");
+ check(strpbrk(one, "befg") == one+1, 14); /* Finding first. */
+ check(strpbrk(one, "cbr") == one+1, 15); /* With multiple search. */
+ check(strpbrk(one, "db") == one+1, 16); /* Another variant. */
+ check(strpbrk(one, "efgh") == one+6, 17); /* And yet another. */
}
void
@@ -648,60 +657,86 @@ test_strsep (void)
equal(strsep(&cp, ", "), "", 9);
equal(strsep(&cp, ", "), "first", 10); /* Extra delims, 1 tok. */
equal(strsep(&cp, ", "), "", 11);
- check(strsep(&cp, ", ") == NULL, 12);
+ equal(strsep(&cp, ", "), "", 12);
+ check(strsep(&cp, ", ") == NULL, 13);
cp = strcpy(one, "1a, 1b; 2a, 2b");
- equal(strsep(&cp, ", "), "1a", 13); /* Changing delim lists. */
- equal(strsep(&cp, ", "), "", 14);
- equal(strsep(&cp, "; "), "1b", 15);
- equal(strsep(&cp, ", "), "", 16);
- equal(strsep(&cp, ", "), "2a", 17);
+ equal(strsep(&cp, ", "), "1a", 14); /* Changing delim lists. */
+ equal(strsep(&cp, ", "), "", 15);
+ equal(strsep(&cp, "; "), "1b", 16);
+ equal(strsep(&cp, ", "), "", 17);
+ equal(strsep(&cp, ", "), "2a", 18);
cp = strcpy(two, "x-y");
- equal(strsep(&cp, "-"), "x", 18); /* New string before done. */
- equal(strsep(&cp, "-"), "y", 19);
- check(strsep(&cp, "-") == NULL, 20);
- cp = strcpy(one, "a,b, c,, ,d");
- equal(strsep(&cp, ", "), "a", 21); /* Different separators. */
- equal(strsep(&cp, ", "), "b", 22);
- equal(strsep(&cp, " ,"), "", 23);
- equal(strsep(&cp, " ,"), "c", 24); /* Permute list too. */
- equal(strsep(&cp, " ,"), "", 25);
+ equal(strsep(&cp, "-"), "x", 19); /* New string before done. */
+ equal(strsep(&cp, "-"), "y", 20);
+ check(strsep(&cp, "-") == NULL, 21);
+ cp = strcpy(one, "a,b, c,, ,d ");
+ equal(strsep(&cp, ", "), "a", 22); /* Different separators. */
+ equal(strsep(&cp, ", "), "b", 23);
+ equal(strsep(&cp, " ,"), "", 24);
+ equal(strsep(&cp, " ,"), "c", 25); /* Permute list too. */
equal(strsep(&cp, " ,"), "", 26);
equal(strsep(&cp, " ,"), "", 27);
- equal(strsep(&cp, " ,"), "d", 28);
- check(strsep(&cp, ", ") == NULL, 29);
- check(strsep(&cp, ", ") == NULL, 30); /* Persistence. */
+ equal(strsep(&cp, " ,"), "", 28);
+ equal(strsep(&cp, " ,"), "d", 29);
+ equal(strsep(&cp, " ,"), "", 30);
+ check(strsep(&cp, ", ") == NULL, 31);
+ check(strsep(&cp, ", ") == NULL, 32); /* Persistence. */
cp = strcpy(one, ", ");
- equal(strsep(&cp, ", "), "", 31);
- equal(strsep(&cp, ", "), "", 32);
- check(strsep(&cp, ", ") == NULL, 33); /* No tokens. */
+ equal(strsep(&cp, ", "), "", 33);
+ equal(strsep(&cp, ", "), "", 34);
+ equal(strsep(&cp, ", "), "", 35);
+ check(strsep(&cp, ", ") == NULL, 36); /* No tokens. */
cp = strcpy(one, "");
- check(strsep(&cp, ", ") == NULL, 34); /* Empty string. */
+ equal(strsep(&cp, ", "), "", 37);
+ check(strsep(&cp, ", ") == NULL, 38); /* Empty string. */
cp = strcpy(one, "abc");
- equal(strsep(&cp, ", "), "abc", 35); /* No delimiters. */
- check(strsep(&cp, ", ") == NULL, 36);
+ equal(strsep(&cp, ", "), "abc", 39); /* No delimiters. */
+ check(strsep(&cp, ", ") == NULL, 40);
cp = strcpy(one, "abc");
- equal(strsep(&cp, ""), "abc", 37); /* Empty delimiter list. */
- check(strsep(&cp, "") == NULL, 38);
+ equal(strsep(&cp, ""), "abc", 41); /* Empty delimiter list. */
+ check(strsep(&cp, "") == NULL, 42);
(void) strcpy(one, "abcdefgh");
cp = strcpy(one, "a,b,c");
- equal(strsep(&cp, ","), "a", 39); /* Basics again... */
- equal(strsep(&cp, ","), "b", 40);
- equal(strsep(&cp, ","), "c", 41);
- check(strsep(&cp, ",") == NULL, 42);
- equal(one+6, "gh", 43); /* Stomped past end? */
- equal(one, "a", 44); /* Stomped old tokens? */
- equal(one+2, "b", 45);
- equal(one+4, "c", 46);
+ equal(strsep(&cp, ","), "a", 43); /* Basics again... */
+ equal(strsep(&cp, ","), "b", 44);
+ equal(strsep(&cp, ","), "c", 45);
+ check(strsep(&cp, ",") == NULL, 46);
+ equal(one+6, "gh", 47); /* Stomped past end? */
+ equal(one, "a", 48); /* Stomped old tokens? */
+ equal(one+2, "b", 49);
+ equal(one+4, "c", 50);
{
char text[] = "This,is,a,test";
char *list = strdupa (text);
- equal (strsep (&list, ","), "This", 47);
- equal (strsep (&list, ","), "is", 48);
- equal (strsep (&list, ","), "a", 49);
- equal (strsep (&list, ","), "test", 50);
- check (strsep (&list, ",") == NULL, 51);
+ equal (strsep (&list, ","), "This", 51);
+ equal (strsep (&list, ","), "is", 52);
+ equal (strsep (&list, ","), "a", 53);
+ equal (strsep (&list, ","), "test", 54);
+ check (strsep (&list, ",") == NULL, 55);
}
+
+ cp = strcpy(one, "a,b, c,, ,d,");
+ equal(strsep(&cp, ","), "a", 56); /* Different separators. */
+ equal(strsep(&cp, ","), "b", 57);
+ equal(strsep(&cp, ","), " c", 58); /* Permute list too. */
+ equal(strsep(&cp, ","), "", 59);
+ equal(strsep(&cp, ","), " ", 60);
+ equal(strsep(&cp, ","), "d", 61);
+ equal(strsep(&cp, ","), "", 62);
+ check(strsep(&cp, ",") == NULL, 63);
+ check(strsep(&cp, ",") == NULL, 64); /* Persistence. */
+
+ cp = strcpy(one, "a,b, c,, ,d,");
+ equal(strsep(&cp, "xy,"), "a", 65); /* Different separators. */
+ equal(strsep(&cp, "x,y"), "b", 66);
+ equal(strsep(&cp, ",xy"), " c", 67); /* Permute list too. */
+ equal(strsep(&cp, "xy,"), "", 68);
+ equal(strsep(&cp, "x,y"), " ", 69);
+ equal(strsep(&cp, ",xy"), "d", 70);
+ equal(strsep(&cp, "xy,"), "", 71);
+ check(strsep(&cp, "x,y") == NULL, 72);
+ check(strsep(&cp, ",xy") == NULL, 73); /* Persistence. */
}
void