projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
qacl: port to Windows better
[gnulib.git]
/
tests
/
test-array-mergesort.c
diff --git
a/tests/test-array-mergesort.c
b/tests/test-array-mergesort.c
index
8a47b67
..
733e64d
100644
(file)
--- a/
tests/test-array-mergesort.c
+++ b/
tests/test-array-mergesort.c
@@
-1,5
+1,5
@@
/* Test of stable-sorting of an array using mergesort.
/* Test of stable-sorting of an array using mergesort.
- Copyright (C) 2009 Free Software Foundation, Inc.
+ Copyright (C) 2009
-2013
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
@@
-24,20
+24,9
@@
struct foo { double x; double index; };
#define STATIC static
#include "array-mergesort.h"
#define STATIC static
#include "array-mergesort.h"
-#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
- while (0)
+#include "macros.h"
#define NMAX 257
static const struct foo data[NMAX] =
#define NMAX 257
static const struct foo data[NMAX] =
@@
-305,8
+294,8
@@
static int
cmp_double (const void *a, const void *b)
{
return (*(const double *)a < *(const double *)b ? -1 :
cmp_double (const void *a, const void *b)
{
return (*(const double *)a < *(const double *)b ? -1 :
- *(const double *)a > *(const double *)b ? 1 :
- 0);
+
*(const double *)a > *(const double *)b ? 1 :
+
0);
}
int
}
int
@@
-336,15
+325,15
@@
main ()
/* Verify the result. */
qsort_result = (double *) malloc (n * sizeof (double));
for (i = 0; i < n; i++)
/* Verify the result. */
qsort_result = (double *) malloc (n * sizeof (double));
for (i = 0; i < n; i++)
- qsort_result[i] = data[i].x;
+
qsort_result[i] = data[i].x;
qsort (qsort_result, n, sizeof (double), cmp_double);
for (i = 0; i < n; i++)
qsort (qsort_result, n, sizeof (double), cmp_double);
for (i = 0; i < n; i++)
- ASSERT (dst[i].x == qsort_result[i]);
+
ASSERT (dst[i].x == qsort_result[i]);
/* Verify the stability. */
for (i = 0; i < n; i++)
/* Verify the stability. */
for (i = 0; i < n; i++)
- if (i > 0 && dst[i - 1].x == dst[i].x)
- ASSERT (dst[i - 1].index < dst[i].index);
+
if (i > 0 && dst[i - 1].x == dst[i].x)
+
ASSERT (dst[i - 1].index < dst[i].index);
free (qsort_result);
free (tmp);
free (qsort_result);
free (tmp);
@@
-365,7
+354,7
@@
main ()
tmp[n].x = 0x587EF149; /* canary */
for (i = 0; i < n; i++)
tmp[n].x = 0x587EF149; /* canary */
for (i = 0; i < n; i++)
- src[i] = data[i];
+
src[i] = data[i];
merge_sort_inplace (src, n, tmp);
merge_sort_inplace (src, n, tmp);
@@
-376,15
+365,15
@@
main ()
/* Verify the result. */
qsort_result = (double *) malloc (n * sizeof (double));
for (i = 0; i < n; i++)
/* Verify the result. */
qsort_result = (double *) malloc (n * sizeof (double));
for (i = 0; i < n; i++)
- qsort_result[i] = data[i].x;
+
qsort_result[i] = data[i].x;
qsort (qsort_result, n, sizeof (double), cmp_double);
for (i = 0; i < n; i++)
qsort (qsort_result, n, sizeof (double), cmp_double);
for (i = 0; i < n; i++)
- ASSERT (src[i].x == qsort_result[i]);
+
ASSERT (src[i].x == qsort_result[i]);
/* Verify the stability. */
for (i = 0; i < n; i++)
/* Verify the stability. */
for (i = 0; i < n; i++)
- if (i > 0 && src[i - 1].x == src[i].x)
- ASSERT (src[i - 1].index < src[i].index);
+
if (i > 0 && src[i - 1].x == src[i].x)
+
ASSERT (src[i - 1].index < src[i].index);
free (qsort_result);
free (tmp);
free (qsort_result);
free (tmp);