X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-strchrnul.c;h=6ea8adc312d6b0a750b653c6f2304204f3fc24eb;hb=3e5de6c5160e5d0263c789120e43d52f0d5fc819;hp=fb26535e55d6477a617b068895818052229559ae;hpb=d2a45d9a8b6d045041db52a37fc7e1226d12deec;p=gnulib.git diff --git a/tests/test-strchrnul.c b/tests/test-strchrnul.c index fb26535e5..6ea8adc31 100644 --- a/tests/test-strchrnul.c +++ b/tests/test-strchrnul.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Free Software Foundation + * Copyright (C) 2008-2011 Free Software Foundation, Inc. * Written by Eric Blake and Bruno Haible * * This program is free software: you can redistribute it and/or modify @@ -19,23 +19,15 @@ #include -#include +#include "signature.h" +SIGNATURE_CHECK (strchrnul, char *, (char const *, int)); + #include -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ - abort (); \ - } \ - } \ - while (0) +#include "macros.h" int -main () +main (void) { size_t n = 0x100000; char *input = malloc (n + 1); @@ -67,7 +59,7 @@ main () size_t repeat = 10000; for (; repeat > 0; repeat--) { - ASSERT (strchrnul (input, 'c') == input + 2); + ASSERT (strchrnul (input, 'c') == input + 2); } } @@ -76,15 +68,15 @@ main () int i, j; for (i = 0; i < 32; i++) { - for (j = 0; j < 256; j++) - input[i + j] = (j + 1) & 0xff; - for (j = 1; j < 256; j++) - { - ASSERT (strchrnul (input + i, j) == input + i + j - 1); - input[i + j - 1] = (j == 1 ? 2 : 1); - ASSERT (strchrnul (input + i, j) == input + i + 255); - input[i + j - 1] = j; - } + for (j = 0; j < 256; j++) + input[i + j] = (j + 1) & 0xff; + for (j = 1; j < 256; j++) + { + ASSERT (strchrnul (input + i, j) == input + i + j - 1); + input[i + j - 1] = (j == 1 ? 2 : 1); + ASSERT (strchrnul (input + i, j) == input + i + 255); + input[i + j - 1] = j; + } } }