X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Funistr%2Ftest-strchr.h;h=9a22fb741233cabc32566ea3cc65b3ca4168dac9;hb=c8068b3df116650efbf0fbf2d790c706577ae972;hp=f280406eb183e93799af4e42e45141c8be5c2df5;hpb=870daa58035b4bb39549f15d20ad1422dd649d63;p=gnulib.git diff --git a/tests/unistr/test-strchr.h b/tests/unistr/test-strchr.h index f280406eb..9a22fb741 100644 --- a/tests/unistr/test-strchr.h +++ b/tests/unistr/test-strchr.h @@ -1,4 +1,4 @@ -/* Test of uN_chr() functions. +/* Test of uN_strchr() functions. Copyright (C) 2008-2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify @@ -17,8 +17,8 @@ /* Written by Paolo Bonzini , 2010. Based on test-chr.h, by Eric Blake and Bruno Haible. */ -int -main (void) +static void +test_strchr (void) { size_t size = 0x100000; size_t length; @@ -101,8 +101,7 @@ main (void) } } - /* Check that uN_chr() does not read past the first occurrence of the - byte being searched. */ + /* Check that uN_strchr() does not read past the end of the string. */ { char *page_boundary = (char *) zerosize_ptr (); size_t n; @@ -122,7 +121,34 @@ main (void) } } - free (input); + /* Check that uN_strchr() does not read past the first occurrence of the + byte being searched. */ + { + char *page_boundary = (char *) zerosize_ptr (); + size_t n; + + if (page_boundary != NULL) + { + for (n = 2; n <= 500 / sizeof (UNIT); n++) + { + UNIT *mem = (UNIT *) (page_boundary - n * sizeof (UNIT)); + U_SET (mem, 'X', n - 1); + mem[n - 1] = 0; + ASSERT (U_STRCHR (mem, 'U') == NULL); + + { + size_t i; - return 0; + for (i = 0; i < n; i++) + { + mem[i] = 'U'; + ASSERT (U_STRCHR (mem, 'U') == mem + i); + mem[i] = 'X'; + } + } + } + } + } + + free (input); }