From 7ea1fac8cffd51fcdd8aa62e3a6ef0691abeece3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 8 Feb 2011 11:18:45 +0100 Subject: [PATCH] ino-map tests: Refactor. * tests/test-ino-map.c: Include ino-map.h early. Include macros.h. Drop unnecessary includes. (ASSERT): Remove macro. (main): Make C90 compliant by avoiding variable declaration after statement. * modules/ino-map-tests (Files): Add tests/macros.h. --- ChangeLog | 10 ++++++++++ modules/ino-map-tests | 1 + tests/test-ino-map.c | 30 +++++++++--------------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2703b2dfe..61bc9aa43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-02-08 Bruno Haible + + ino-map tests: Refactor. + * tests/test-ino-map.c: Include ino-map.h early. Include macros.h. Drop + unnecessary includes. + (ASSERT): Remove macro. + (main): Make C90 compliant by avoiding variable declaration after + statement. + * modules/ino-map-tests (Files): Add tests/macros.h. + 2011-02-08 Jim Meyering di-set: add "const" to a cast diff --git a/modules/ino-map-tests b/modules/ino-map-tests index fa10b4ffc..349b994ff 100644 --- a/modules/ino-map-tests +++ b/modules/ino-map-tests @@ -1,5 +1,6 @@ Files: tests/test-ino-map.c +tests/macros.h Depends-on: diff --git a/tests/test-ino-map.c b/tests/test-ino-map.c index 12ad9f866..ef259715f 100644 --- a/tests/test-ino-map.c +++ b/tests/test-ino-map.c @@ -17,25 +17,11 @@ /* Written by Jim Meyering. */ #include -#include -#include -#include - -/* FIXME: once/if in gnulib, use #include "macros.h" in place of this */ -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ - abort (); \ - } \ - } \ - while (0) #include "ino-map.h" +#include "macros.h" + int main () { @@ -50,11 +36,13 @@ main () ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2); ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2); - int i; - for (i = 0; i < 100; i++) - { - ASSERT (ino_map_insert (ino_map, 10000 + i) == INO_MAP_INIT + 3 + i); - } + { + int i; + for (i = 0; i < 100; i++) + { + ASSERT (ino_map_insert (ino_map, 10000 + i) == INO_MAP_INIT + 3 + i); + } + } ino_map_free (ino_map); -- 2.11.0