aboutsummaryrefslogtreecommitdiff
path: root/string/tester.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-05-03 23:44:29 +0000
committerUlrich Drepper <drepper@redhat.com>1999-05-03 23:44:29 +0000
commite0faeea74fc885c53f03b1cc3a3b90aef51185ce (patch)
tree1a261917e4efe192a0a97bb97c6006fee33b2d54 /string/tester.c
parent6dc0d457ecab90cad69f62ffd0386a8f4830f38e (diff)
downloadglibc-e0faeea74fc885c53f03b1cc3a3b90aef51185ce.tar
glibc-e0faeea74fc885c53f03b1cc3a3b90aef51185ce.tar.gz
glibc-e0faeea74fc885c53f03b1cc3a3b90aef51185ce.tar.bz2
glibc-e0faeea74fc885c53f03b1cc3a3b90aef51185ce.zip
Update.
* string/tester.c: Add test of rawmemchr.
Diffstat (limited to 'string/tester.c')
-rw-r--r--string/tester.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/string/tester.c b/string/tester.c
index 96c7aa219c..fbadbb05a6 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -443,6 +443,33 @@ test_strchrnul (void)
}
void
+test_rawmemchr (void)
+{
+ it = "rawmemchr";
+ (void) strcpy (one, "abcd");
+ check (rawmemchr (one, 'c') == one+2, 1); /* Basic test. */
+ check (rawmemchr (one, 'd') == one+3, 2); /* End of string. */
+ check (rawmemchr (one, 'a') == one, 3); /* Beginning. */
+ check (rawmemchr (one, '\0') == one+4, 4); /* Finding NUL. */
+ (void) strcpy (one, "ababa");
+ check (rawmemchr (one, 'b') == one+1, 5); /* Finding first. */
+ (void) strcpy (one, "");
+ check (rawmemchr (one, '\0') == one, 6); /* NUL in empty string. */
+ {
+ char buf[4096];
+ int i;
+ char *p;
+ for (i=0; i < 0x100; i++)
+ {
+ p = (char *) ((unsigned long int) (buf + 0xff) & ~0xff) + i;
+ strcpy (p, "OK");
+ strcpy (p+3, "BAD/WRONG");
+ check (rawmemchr (p, 'R') == p+8, 6+i);
+ }
+ }
+}
+
+void
test_index (void)
{
it = "index";
@@ -1099,6 +1126,9 @@ main (void)
/* strchrnul. */
test_strchrnul ();
+ /* rawmemchr. */
+ test_rawmemchr ();
+
/* index - just like strchr. */
test_index ();