annotate tests/test-array-mergesort.c @ 12559:c2cbabec01dd

update nearly all FSF copyright year lists to include 2010 Use the same procedure as for 2009, outlined in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
author Jim Meyering <meyering@redhat.com>
date Fri, 01 Jan 2010 10:31:12 +0100
parents a48d3d749ca5
children 97fc9a21a8fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of stable-sorting of an array using mergesort.
12559
c2cbabec01dd update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents: 12496
diff changeset
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify it
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 under the terms of the GNU Lesser General Public License as published
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 by the Free Software Foundation; either version 3 of the License, or
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 Lesser General Public License for more details.
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU Lesser General Public License
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <stddef.h>
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 struct foo { double x; double index; };
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #define ELEMENT struct foo
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #define COMPARE(a,b) ((a)->x < (b)->x ? -1 : (a)->x > (b)->x ? 1 : 0)
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #define STATIC static
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include "array-mergesort.h"
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include <stdlib.h>
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
12496
a48d3d749ca5 Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents: 12421
diff changeset
29 #include "macros.h"
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 #define NMAX 257
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 static const struct foo data[NMAX] =
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 {
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 { 2, 0 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 { 28, 1 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 { 36, 2 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 { 43, 3 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 { 20, 4 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 { 37, 5 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 { 19, 6 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 { 37, 7 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 { 30, 8 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 { 18, 9 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 { 30, 10 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 { 49, 11 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 { 16, 12 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 { 22, 13 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 { 23, 14 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 { 3, 15 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 { 39, 16 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 { 48, 17 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 { 18, 18 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 { 18, 19 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 { 45, 20 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 { 39, 21 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 { 1, 22 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 { 44, 23 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 { 24, 24 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 { 21, 25 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 { 29, 26 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 { 3, 27 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 { 34, 28 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 { 15, 29 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 { 39, 30 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 { 11, 31 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 { 29, 32 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 { 27, 33 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 { 43, 34 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 { 31, 35 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 { 28, 36 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 { 12, 37 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 { 16, 38 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 { 34, 39 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74 { 25, 40 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 { 31, 41 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 { 29, 42 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 { 36, 43 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 { 17, 44 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 { 18, 45 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 { 44, 46 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 { 22, 47 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 { 23, 48 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 { 32, 49 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 { 16, 50 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 { 47, 51 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 { 28, 52 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 { 46, 53 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 { 49, 54 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 { 24, 55 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 { 0, 56 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 { 20, 57 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92 { 25, 58 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 { 42, 59 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 { 48, 60 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 { 16, 61 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 { 26, 62 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 { 32, 63 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98 { 24, 64 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 { 17, 65 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 { 47, 66 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 { 47, 67 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 { 12, 68 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 { 33, 69 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 { 41, 70 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 { 36, 71 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 { 8, 72 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 { 15, 73 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 { 0, 74 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 { 32, 75 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 { 28, 76 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 { 11, 77 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 { 46, 78 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 { 34, 79 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 { 5, 80 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 { 20, 81 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 { 47, 82 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 { 25, 83 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 { 7, 84 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 { 29, 85 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 { 40, 86 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 { 5, 87 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 { 12, 88 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 { 30, 89 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 { 1, 90 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 { 22, 91 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 { 29, 92 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 { 42, 93 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128 { 49, 94 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 { 30, 95 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 { 40, 96 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 { 33, 97 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 { 36, 98 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 { 12, 99 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 { 8, 100 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 { 33, 101 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 { 5, 102 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137 { 31, 103 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 { 27, 104 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 { 19, 105 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 { 43, 106 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 { 37, 107 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 { 9, 108 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143 { 40, 109 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 { 0, 110 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145 { 35, 111 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146 { 32, 112 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 { 6, 113 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 { 27, 114 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149 { 28, 115 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 { 30, 116 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 { 37, 117 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 { 32, 118 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 { 41, 119 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 { 14, 120 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 { 44, 121 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156 { 22, 122 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 { 26, 123 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 { 2, 124 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 { 43, 125 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
160 { 20, 126 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 { 32, 127 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 { 24, 128 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
163 { 33, 129 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 { 7, 130 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
165 { 17, 131 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166 { 10, 132 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
167 { 47, 133 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
168 { 14, 134 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
169 { 29, 135 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
170 { 19, 136 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
171 { 25, 137 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
172 { 25, 138 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173 { 13, 139 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174 { 25, 140 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
175 { 32, 141 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176 { 8, 142 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177 { 37, 143 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178 { 31, 144 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
179 { 32, 145 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
180 { 5, 146 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181 { 45, 147 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
182 { 35, 148 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
183 { 47, 149 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184 { 3, 150 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
185 { 4, 151 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
186 { 37, 152 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
187 { 43, 153 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
188 { 39, 154 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
189 { 18, 155 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
190 { 13, 156 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
191 { 15, 157 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
192 { 41, 158 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
193 { 34, 159 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
194 { 4, 160 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
195 { 33, 161 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
196 { 20, 162 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
197 { 4, 163 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
198 { 38, 164 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
199 { 47, 165 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200 { 30, 166 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201 { 41, 167 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202 { 23, 168 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203 { 40, 169 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 { 23, 170 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 { 35, 171 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206 { 47, 172 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
207 { 32, 173 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
208 { 15, 174 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 { 15, 175 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 { 41, 176 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
211 { 35, 177 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212 { 6, 178 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
213 { 18, 179 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
214 { 35, 180 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215 { 39, 181 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
216 { 34, 182 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217 { 6, 183 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
218 { 34, 184 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
219 { 37, 185 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
220 { 15, 186 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
221 { 6, 187 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
222 { 12, 188 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
223 { 39, 189 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
224 { 9, 190 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
225 { 48, 191 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
226 { 37, 192 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
227 { 28, 193 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
228 { 32, 194 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
229 { 1, 195 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
230 { 45, 196 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
231 { 21, 197 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
232 { 11, 198 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233 { 32, 199 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
234 { 43, 200 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235 { 35, 201 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
236 { 25, 202 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
237 { 4, 203 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238 { 20, 204 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
239 { 10, 205 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
240 { 22, 206 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
241 { 44, 207 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
242 { 30, 208 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
243 { 16, 209 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
244 { 42, 210 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
245 { 13, 211 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
246 { 29, 212 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
247 { 23, 213 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
248 { 30, 214 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
249 { 25, 215 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
250 { 49, 216 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251 { 0, 217 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
252 { 49, 218 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
253 { 29, 219 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
254 { 37, 220 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
255 { 6, 221 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 { 27, 222 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257 { 31, 223 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
258 { 17, 224 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
259 { 45, 225 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
260 { 25, 226 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
261 { 15, 227 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
262 { 34, 228 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
263 { 7, 229 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
264 { 7, 230 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
265 { 4, 231 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
266 { 31, 232 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
267 { 40, 233 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
268 { 17, 234 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 { 2, 235 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270 { 34, 236 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271 { 17, 237 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
272 { 25, 238 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273 { 5, 239 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
274 { 48, 240 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275 { 31, 241 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 { 41, 242 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 { 45, 243 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 { 33, 244 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
279 { 46, 245 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
280 { 19, 246 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
281 { 17, 247 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
282 { 38, 248 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
283 { 43, 249 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
284 { 16, 250 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
285 { 5, 251 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 { 21, 252 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
287 { 0, 253 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
288 { 47, 254 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
289 { 40, 255 },
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
290 { 22, 256 }
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
291 };
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
292
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
293 static int
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
294 cmp_double (const void *a, const void *b)
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
295 {
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
296 return (*(const double *)a < *(const double *)b ? -1 :
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
297 *(const double *)a > *(const double *)b ? 1 :
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
298 0);
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
299 }
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
300
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
301 int
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
302 main ()
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
303 {
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
304 size_t n;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
305
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
306 /* Test merge_sort_fromto. */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
307 for (n = 1; n <= NMAX; n++)
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
308 {
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
309 struct foo *dst;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
310 struct foo *tmp;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
311 double *qsort_result;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
312 size_t i;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
313
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
314 dst = (struct foo *) malloc ((n + 1) * sizeof (struct foo));
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
315 dst[n].x = 0x4A6A71FE; /* canary */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
316 tmp = (struct foo *) malloc ((n / 2 + 1) * sizeof (struct foo));
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
317 tmp[n / 2].x = 0x587EF149; /* canary */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
318
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
319 merge_sort_fromto (data, dst, n, tmp);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
320
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
321 /* Verify the canaries. */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
322 ASSERT (dst[n].x == 0x4A6A71FE);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
323 ASSERT (tmp[n / 2].x == 0x587EF149);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
324
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
325 /* Verify the result. */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
326 qsort_result = (double *) malloc (n * sizeof (double));
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
327 for (i = 0; i < n; i++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
328 qsort_result[i] = data[i].x;
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
329 qsort (qsort_result, n, sizeof (double), cmp_double);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
330 for (i = 0; i < n; i++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
331 ASSERT (dst[i].x == qsort_result[i]);
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
332
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
333 /* Verify the stability. */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
334 for (i = 0; i < n; i++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
335 if (i > 0 && dst[i - 1].x == dst[i].x)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
336 ASSERT (dst[i - 1].index < dst[i].index);
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
337
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
338 free (qsort_result);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
339 free (tmp);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
340 free (dst);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
341 }
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
342
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
343 /* Test merge_sort_inplace. */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
344 for (n = 1; n <= NMAX; n++)
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
345 {
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
346 struct foo *src;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
347 struct foo *tmp;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
348 double *qsort_result;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
349 size_t i;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
350
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
351 src = (struct foo *) malloc ((n + 1) * sizeof (struct foo));
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
352 src[n].x = 0x4A6A71FE; /* canary */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
353 tmp = (struct foo *) malloc ((n + 1) * sizeof (struct foo));
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
354 tmp[n].x = 0x587EF149; /* canary */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
355
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
356 for (i = 0; i < n; i++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
357 src[i] = data[i];
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
358
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
359 merge_sort_inplace (src, n, tmp);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
360
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
361 /* Verify the canaries. */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
362 ASSERT (src[n].x == 0x4A6A71FE);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
363 ASSERT (tmp[n].x == 0x587EF149);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
364
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
365 /* Verify the result. */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
366 qsort_result = (double *) malloc (n * sizeof (double));
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
367 for (i = 0; i < n; i++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
368 qsort_result[i] = data[i].x;
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
369 qsort (qsort_result, n, sizeof (double), cmp_double);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
370 for (i = 0; i < n; i++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
371 ASSERT (src[i].x == qsort_result[i]);
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
372
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
373 /* Verify the stability. */
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
374 for (i = 0; i < n; i++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
375 if (i > 0 && src[i - 1].x == src[i].x)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 11168
diff changeset
376 ASSERT (src[i - 1].index < src[i].index);
11168
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
377
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
378 free (qsort_result);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
379 free (tmp);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
380 free (src);
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
381 }
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
382
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
383 return 0;
8efaede722cf Tests for module 'array-mergesort'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
384 }