added minmax
[pspp-builds.git] / tests / libpspp / ll-test.c
index 1ec96ed5ddb5b9ac9b9631871c269d4dd18942a0..324b3d1389de4fb554dd3e5ed932aa461815e3d4 100644 (file)
@@ -1,6 +1,5 @@
 /* PSPP - computes sample statistics.
    Copyright (C) 2006 Free Software Foundation, Inc.
-   Written by Ben Pfaff <blp@gnu.org>.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
    See llx-test.c for a similar program for the llx_*
    routines. */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <libpspp/ll.h>
 #include <assert.h>
 #include <stdio.h>
@@ -42,6 +45,9 @@
 #define UNUSED
 #endif
 
+/* Currently running test. */
+static const char *test_name;
+
 /* Exit with a failure code.
    (Place a breakpoint on this function while debugging.) */
 static void
@@ -57,7 +63,8 @@ check_func (bool ok, int line)
 {
   if (!ok) 
     {
-      printf ("check failed at %s, line %d\n", __FILE__, line);
+      printf ("Check failed in %s test at %s, line %d\n",
+              test_name, __FILE__, line);
       check_die ();
     }
 }
@@ -209,7 +216,7 @@ static bool
 pattern_pred (const struct ll *element_, void *pattern_) 
 {
   const struct element *element = ll_to_element (element_);
-  unsigned *pattern = pattern_;
+  unsigned int *pattern = pattern_;
 
   return (*pattern & (1u << element->x)) != 0;
 }
@@ -1015,10 +1022,10 @@ test_count_if (void)
 }
 
 /* Returns N!. */
-static unsigned
-factorial (unsigned n) 
+static unsigned int
+factorial (unsigned int n) 
 {
-  unsigned value = 1;
+  unsigned int value = 1;
   while (n > 1)
     value *= n--;
   return value;
@@ -1027,11 +1034,11 @@ factorial (unsigned n)
 /* Returns the number of permutations of the CNT values in
    VALUES.  If VALUES contains duplicates, they must be
    adjacent. */
-static unsigned
+static unsigned int
 expected_perms (int *values, size_t cnt) 
 {
   size_t i, j;
-  unsigned perm_cnt;
+  unsigned int perm_cnt;
   
   perm_cnt = factorial (cnt);
   for (i = 0; i < cnt; i = j) 
@@ -1335,7 +1342,7 @@ test_permutations_with_dups (void)
         int *old_values = xnmalloc (max_elems, sizeof *values);
         int *new_values = xnmalloc (max_elems, sizeof *values);
 
-        unsigned permutation_cnt;
+        unsigned int permutation_cnt;
         int left = cnt;
         int value = 0;
       
@@ -1892,7 +1899,7 @@ test_partition (void)
   const int max_elems = 10;
   
   int cnt;
-  unsigned pbase;
+  unsigned int pbase;
   int r0, r1;
 
   for (cnt = 0; cnt < max_elems; cnt++)
@@ -1905,7 +1912,7 @@ test_partition (void)
             struct ll **elemp;
             int *values;
 
-            unsigned pattern = pbase << r0;
+            unsigned int pattern = pbase << r0;
             int i, j;
             int first_false;
             struct ll *part_ll;
@@ -1971,10 +1978,10 @@ test_partition (void)
 static void
 run_test (void (*test_function) (void), const char *name) 
 {
-  printf ("Running %s test...  ", name);
+  test_name = name;
+  putchar ('.');
   fflush (stdout);
   test_function ();
-  printf ("done.\n");
 }
 
 int
@@ -2010,6 +2017,7 @@ main (void)
   run_test (test_sort_unique, "sort_unique");
   run_test (test_insert_ordered, "insert_ordered");
   run_test (test_partition, "partition");
+  putchar ('\n');
 
   return 0;
 }