diff options
author | Andreas Schwab <schwab@redhat.com> | 2011-10-13 12:39:24 +0200 |
---|---|---|
committer | Andreas Schwab <schwab@redhat.com> | 2011-10-13 13:34:41 +0200 |
commit | 5298ffa828f2a7fe9e16c7f8971273a36a7530e6 (patch) | |
tree | ce0c5a326cbb1db57155111ada40f0064c229888 /string | |
parent | f9e123204e9a96d421c9f9ce011d567ce9f8e217 (diff) | |
download | glibc-5298ffa828f2a7fe9e16c7f8971273a36a7530e6.tar glibc-5298ffa828f2a7fe9e16c7f8971273a36a7530e6.tar.gz glibc-5298ffa828f2a7fe9e16c7f8971273a36a7530e6.tar.bz2 glibc-5298ffa828f2a7fe9e16c7f8971273a36a7530e6.zip |
Add memrchr tests
Diffstat (limited to 'string')
-rw-r--r-- | string/stratcliff.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/string/stratcliff.c b/string/stratcliff.c index 5165be2d13..5176409c5b 100644 --- a/string/stratcliff.c +++ b/string/stratcliff.c @@ -1,5 +1,5 @@ /* Test for string function add boundaries of usable memory. - Copyright (C) 1996,1997,1999-2003,2007,2009,2010 + Copyright (C) 1996,1997,1999-2003,2007,2009,2010,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. @@ -240,7 +240,7 @@ do_test (void) } } - /* This function only exists for single-byte characters. */ + /* These functions only exist for single-byte characters. */ #ifndef WCSTEST /* rawmemchr test */ for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) @@ -261,6 +261,37 @@ do_test (void) adr[middle] = L('T'); } } + + /* memrchr test */ + for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer) + { + for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle) + { + adr[middle] = L('V'); + + CHAR *cp = memrchr (&adr[outer], L('V'), nchars - outer); + + if (cp - &adr[outer] != middle - outer) + { + printf ("%s flunked for outer = %d, middle = %d\n", + STRINGIFY (memrchr), outer, middle); + result = 1; + } + + adr[middle] = L('T'); + } + } + for (outer = nchars; outer >= MAX (0, nchars - 128); --outer) + { + CHAR *cp = memrchr (&adr[outer], L('V'), nchars - outer); + + if (cp != NULL) + { + printf ("%s flunked for outer = %d\n", + STRINGIFY (memrchr), outer); + result = 1; + } + } #endif /* strcpy/wcscpy test */ |