changeset 14309:93b787ac4b80

di-set tests: Refactor. * tests/test-di-set.c: Include di-set.h early. Include macros.h. Drop unnecessary includes. (ASSERT): Remove macro. (main): Make C90 compliant by avoiding variable declaration after statement. * modules/di-set-tests (Files): Add tests/macros.h.
author Bruno Haible <bruno@clisp.org>
date Tue, 08 Feb 2011 11:20:08 +0100
parents 3bdf4414b758
children 00537d144c48
files ChangeLog modules/di-set-tests tests/test-di-set.c
diffstat 3 files changed, 20 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Feb 08 11:18:45 2011 +0100
+++ b/ChangeLog	Tue Feb 08 11:20:08 2011 +0100
@@ -1,3 +1,13 @@
+2011-02-08  Bruno Haible  <bruno@clisp.org>
+
+	di-set tests: Refactor.
+	* tests/test-di-set.c: Include di-set.h early. Include macros.h. Drop
+	unnecessary includes.
+	(ASSERT): Remove macro.
+	(main): Make C90 compliant by avoiding variable declaration after
+	statement.
+	* modules/di-set-tests (Files): Add tests/macros.h.
+
 2011-02-08  Bruno Haible  <bruno@clisp.org>
 
 	ino-map tests: Refactor.
--- a/modules/di-set-tests	Tue Feb 08 11:18:45 2011 +0100
+++ b/modules/di-set-tests	Tue Feb 08 11:20:08 2011 +0100
@@ -1,5 +1,6 @@
 Files:
 tests/test-di-set.c
+tests/macros.h
 
 Depends-on:
 
--- a/tests/test-di-set.c	Tue Feb 08 11:18:45 2011 +0100
+++ b/tests/test-di-set.c	Tue Feb 08 11:20:08 2011 +0100
@@ -17,25 +17,11 @@
 /* Written by Jim Meyering.  */
 
 #include <config.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-
-#define ASSERT(expr) \
-  do                                                                         \
-    {                                                                        \
-      if (!(expr))                                                           \
-        {                                                                    \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);                                                   \
-          abort ();                                                          \
-        }                                                                    \
-    }                                                                        \
-  while (0)
 
 #include "di-set.h"
 
+#include "macros.h"
+
 int
 main (void)
 {
@@ -53,11 +39,13 @@
   ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 1);
   ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 0); /* dup */
 
-  unsigned int i;
-  for (i = 0; i < 3000; i++)
-    ASSERT (di_set_insert (dis, 9, i) == 1);
-  for (i = 0; i < 3000; i++)
-    ASSERT (di_set_insert (dis, 9, i) == 0); /* duplicate fails */
+  {
+    unsigned int i;
+    for (i = 0; i < 3000; i++)
+      ASSERT (di_set_insert (dis, 9, i) == 1);
+    for (i = 0; i < 3000; i++)
+      ASSERT (di_set_insert (dis, 9, i) == 0); /* duplicate fails */
+  }
 
   di_set_free (dis);