ino-map tests: Refactor.
authorBruno Haible <bruno@clisp.org>
Tue, 8 Feb 2011 10:18:45 +0000 (11:18 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 8 Feb 2011 10:22:06 +0000 (11:22 +0100)
* 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
modules/ino-map-tests
tests/test-ino-map.c

index 2703b2dfee5e6febfbb4361652db2b3fba468c90..61bc9aa43195e6a2791519ee05c5f711131aaaa4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-02-08  Bruno Haible  <bruno@clisp.org>
+
+       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  <meyering@redhat.com>
 
        di-set: add "const" to a cast
index fa10b4ffcca9f96008517133e5d79b888fe9e8b8..349b994ff7a86c5460fae8cc7aaaa9d46aa53f51 100644 (file)
@@ -1,5 +1,6 @@
 Files:
 tests/test-ino-map.c
+tests/macros.h
 
 Depends-on:
 
index 12ad9f8666d4e60192a28930214a28999c31c70c..ef259715fcaea06b69d361d1ab88f605eecf6ce7 100644 (file)
 /* Written by Jim Meyering.  */
 
 #include <config.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-/* 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);