Mercurial > hg > octave-shane > gnulib-hg
annotate tests/test-avltreehash_list.c @ 14079:97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Run the new "make update-copyright" rule.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Sat, 01 Jan 2011 20:17:23 +0100 |
parents | c2cbabec01dd |
children | 8250f2777afc |
rev | line source |
---|---|
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of sequential list data type implementation. |
14079
97fc9a21a8fb
maint: update almost all copyright ranges to include 2011
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
2 Copyright (C) 2006-2011 Free Software Foundation, Inc. |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 Written by Bruno Haible <bruno@clisp.org>, 2006. |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
8 (at your option) any later version. |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 |
8891
633babea5f62
Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents:
8754
diff
changeset
|
18 #include <config.h> |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 |
8289
a24f55137420
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6981
diff
changeset
|
20 #include "gl_avltreehash_list.h" |
a24f55137420
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6981
diff
changeset
|
21 |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 #include <limits.h> |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 #include <stdlib.h> |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #include <string.h> |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 #include "gl_array_list.h" |
8289
a24f55137420
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6981
diff
changeset
|
27 #include "progname.h" |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12445
diff
changeset
|
28 #include "macros.h" |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 extern void gl_avltreehash_list_check_invariants (gl_list_t list); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 static const char *objects[15] = |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o" |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 }; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 #define SIZE_BITS (sizeof (size_t) * CHAR_BIT) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 static bool |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 string_equals (const void *x1, const void *x2) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 const char *s1 = x1; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 const char *s2 = x2; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 return strcmp (s1, s2) == 0; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 /* A hash function for NUL-terminated char* strings using |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 the method described by Bruno Haible. |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 See http://www.haible.de/bruno/hashfunc.html. */ |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 static size_t |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 string_hash (const void *x) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 const char *s = x; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 size_t h = 0; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 for (; *s; s++) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 h = *s + ((h << 9) | (h >> (SIZE_BITS - 9))); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 return h; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 #define RANDOM(n) (rand () % (n)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 static void |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 check_equals (gl_list_t list1, gl_list_t list2) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 size_t n, i; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 n = gl_list_size (list1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 ASSERT (n == gl_list_size (list2)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 for (i = 0; i < n; i++) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
76 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 static void |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 check_all (gl_list_t list1, gl_list_t list2, gl_list_t list3) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 gl_avltreehash_list_check_invariants (list2); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
82 gl_avltreehash_list_check_invariants (list3); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
83 check_equals (list1, list2); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
84 check_equals (list1, list3); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
86 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
87 int |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
88 main (int argc, char *argv[]) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
89 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
90 gl_list_t list1, list2, list3; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
91 |
8289
a24f55137420
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6981
diff
changeset
|
92 set_program_name (argv[0]); |
a24f55137420
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6981
diff
changeset
|
93 |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
94 /* Allow the user to provide a non-default random seed on the command line. */ |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
95 if (argc > 1) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
96 srand (atoi (argv[1])); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
97 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
98 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
99 size_t initial_size = RANDOM (50); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
100 const void **contents = |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
101 (const void **) malloc (initial_size * sizeof (const void *)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
102 size_t i; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
103 unsigned int repeat; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
104 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
105 for (i = 0; i < initial_size; i++) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
106 contents[i] = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
107 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
108 /* Create list1. */ |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
109 list1 = gl_list_nx_create (GL_ARRAY_LIST, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
110 string_equals, string_hash, NULL, true, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
111 initial_size, contents); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
112 ASSERT (list1 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
113 /* Create list2. */ |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
114 list2 = gl_list_nx_create_empty (GL_AVLTREEHASH_LIST, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
115 string_equals, string_hash, NULL, true); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
116 ASSERT (list2 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
117 for (i = 0; i < initial_size; i++) |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
118 ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
119 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
120 /* Create list3. */ |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
121 list3 = gl_list_nx_create (GL_AVLTREEHASH_LIST, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
122 string_equals, string_hash, NULL, true, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
123 initial_size, contents); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
124 ASSERT (list3 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
125 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
126 check_all (list1, list2, list3); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
127 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
128 for (repeat = 0; repeat < 10000; repeat++) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
129 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
130 unsigned int operation = RANDOM (16); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
131 switch (operation) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
132 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
133 case 0: |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
134 if (gl_list_size (list1) > 0) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
135 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
136 size_t index = RANDOM (gl_list_size (list1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
137 const char *obj = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
138 gl_list_node_t node1, node2, node3; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
139 |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
140 node1 = gl_list_nx_set_at (list1, index, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
141 ASSERT (node1 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
142 ASSERT (gl_list_get_at (list1, index) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
143 ASSERT (gl_list_node_value (list1, node1) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
144 |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
145 node2 = gl_list_nx_set_at (list2, index, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
146 ASSERT (node2 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
147 ASSERT (gl_list_get_at (list2, index) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
148 ASSERT (gl_list_node_value (list2, node2) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
149 |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
150 node3 = gl_list_nx_set_at (list3, index, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
151 ASSERT (node3 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
152 ASSERT (gl_list_get_at (list3, index) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
153 ASSERT (gl_list_node_value (list3, node3) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
154 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
155 if (index > 0) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
156 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
157 ASSERT (gl_list_node_value (list1, gl_list_previous_node (list1, node1)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
158 == gl_list_get_at (list1, index - 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
159 ASSERT (gl_list_node_value (list2, gl_list_previous_node (list3, node3)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
160 == gl_list_get_at (list2, index - 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
161 ASSERT (gl_list_node_value (list3, gl_list_previous_node (list3, node3)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
162 == gl_list_get_at (list2, index - 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
163 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
164 if (index + 1 < gl_list_size (list1)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
165 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
166 ASSERT (gl_list_node_value (list1, gl_list_next_node (list1, node1)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
167 == gl_list_get_at (list1, index + 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
168 ASSERT (gl_list_node_value (list2, gl_list_next_node (list3, node3)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
169 == gl_list_get_at (list2, index + 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
170 ASSERT (gl_list_node_value (list3, gl_list_next_node (list3, node3)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
171 == gl_list_get_at (list2, index + 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
172 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
173 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
174 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
175 case 1: |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
176 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
177 const char *obj = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
178 gl_list_node_t node1, node2, node3; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
179 node1 = gl_list_search (list1, obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
180 node2 = gl_list_search (list2, obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
181 node3 = gl_list_search (list3, obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
182 if (node1 == NULL) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
183 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
184 ASSERT (node2 == NULL); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
185 ASSERT (node3 == NULL); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
186 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
187 else |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
188 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
189 ASSERT (node2 != NULL); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
190 ASSERT (node3 != NULL); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
191 ASSERT (gl_list_node_value (list1, node1) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
192 ASSERT (gl_list_node_value (list2, node2) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
193 ASSERT (gl_list_node_value (list3, node3) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
194 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
195 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
196 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
197 case 2: |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
198 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
199 const char *obj = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
200 size_t index1, index2, index3; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
201 index1 = gl_list_indexof (list1, obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
202 index2 = gl_list_indexof (list2, obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
203 index3 = gl_list_indexof (list3, obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
204 if (index1 == (size_t)(-1)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
205 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
206 ASSERT (index2 == (size_t)(-1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
207 ASSERT (index3 == (size_t)(-1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
208 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
209 else |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
210 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
211 ASSERT (index2 != (size_t)(-1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
212 ASSERT (index3 != (size_t)(-1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
213 ASSERT (gl_list_get_at (list1, index1) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
214 ASSERT (gl_list_get_at (list2, index2) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
215 ASSERT (gl_list_get_at (list3, index3) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
216 ASSERT (index2 == index1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
217 ASSERT (index3 == index1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
218 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
219 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
220 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
221 case 3: /* add 1 element */ |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
222 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
223 const char *obj = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
224 gl_list_node_t node1, node2, node3; |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
225 node1 = gl_list_nx_add_first (list1, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
226 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
227 node2 = gl_list_nx_add_first (list2, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
228 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
229 node3 = gl_list_nx_add_first (list3, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
230 ASSERT (node3 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
231 ASSERT (gl_list_node_value (list1, node1) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
232 ASSERT (gl_list_node_value (list2, node2) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
233 ASSERT (gl_list_node_value (list3, node3) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
234 ASSERT (gl_list_get_at (list1, 0) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
235 ASSERT (gl_list_get_at (list2, 0) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
236 ASSERT (gl_list_get_at (list3, 0) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
237 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
238 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
239 case 4: /* add 1 element */ |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
240 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
241 const char *obj = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
242 gl_list_node_t node1, node2, node3; |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
243 node1 = gl_list_nx_add_last (list1, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
244 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
245 node2 = gl_list_nx_add_last (list2, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
246 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
247 node3 = gl_list_nx_add_last (list3, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
248 ASSERT (node3 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
249 ASSERT (gl_list_node_value (list1, node1) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
250 ASSERT (gl_list_node_value (list2, node2) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
251 ASSERT (gl_list_node_value (list3, node3) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
252 ASSERT (gl_list_get_at (list1, gl_list_size (list1) - 1) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
253 ASSERT (gl_list_get_at (list2, gl_list_size (list2) - 1) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
254 ASSERT (gl_list_get_at (list3, gl_list_size (list3) - 1) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
255 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
256 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
257 case 5: /* add 3 elements */ |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
258 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
259 const char *obj0 = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
260 const char *obj1 = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
261 const char *obj2 = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
262 gl_list_node_t node1, node2, node3; |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
263 node1 = gl_list_nx_add_first (list1, obj2); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
264 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
265 node1 = gl_list_nx_add_before (list1, node1, obj0); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
266 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
267 node1 = gl_list_nx_add_after (list1, node1, obj1); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
268 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
269 node2 = gl_list_nx_add_first (list2, obj2); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
270 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
271 node2 = gl_list_nx_add_before (list2, node2, obj0); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
272 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
273 node2 = gl_list_nx_add_after (list2, node2, obj1); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
274 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
275 node3 = gl_list_nx_add_first (list3, obj2); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
276 ASSERT (node3 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
277 node3 = gl_list_nx_add_before (list3, node3, obj0); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
278 ASSERT (node3 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
279 node3 = gl_list_nx_add_after (list3, node3, obj1); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
280 ASSERT (node3 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
281 ASSERT (gl_list_node_value (list1, node1) == obj1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
282 ASSERT (gl_list_node_value (list2, node2) == obj1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
283 ASSERT (gl_list_node_value (list3, node3) == obj1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
284 ASSERT (gl_list_get_at (list1, 0) == obj0); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
285 ASSERT (gl_list_get_at (list1, 1) == obj1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
286 ASSERT (gl_list_get_at (list1, 2) == obj2); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
287 ASSERT (gl_list_get_at (list2, 0) == obj0); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
288 ASSERT (gl_list_get_at (list2, 1) == obj1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
289 ASSERT (gl_list_get_at (list2, 2) == obj2); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
290 ASSERT (gl_list_get_at (list3, 0) == obj0); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
291 ASSERT (gl_list_get_at (list3, 1) == obj1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
292 ASSERT (gl_list_get_at (list3, 2) == obj2); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
293 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
294 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
295 case 6: /* add 1 element */ |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
296 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
297 size_t index = RANDOM (gl_list_size (list1) + 1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
298 const char *obj = RANDOM_OBJECT (); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
299 gl_list_node_t node1, node2, node3; |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
300 node1 = gl_list_nx_add_at (list1, index, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
301 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
302 node2 = gl_list_nx_add_at (list2, index, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
303 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
304 node3 = gl_list_nx_add_at (list3, index, obj); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
305 ASSERT (node3 != NULL); |
6981
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
306 ASSERT (gl_list_get_at (list1, index) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
307 ASSERT (gl_list_node_value (list1, node1) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
308 ASSERT (gl_list_get_at (list2, index) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
309 ASSERT (gl_list_node_value (list2, node2) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
310 ASSERT (gl_list_get_at (list3, index) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
311 ASSERT (gl_list_node_value (list3, node3) == obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
312 if (index > 0) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
313 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
314 ASSERT (gl_list_node_value (list1, gl_list_previous_node (list1, node1)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
315 == gl_list_get_at (list1, index - 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
316 ASSERT (gl_list_node_value (list2, gl_list_previous_node (list3, node3)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
317 == gl_list_get_at (list2, index - 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
318 ASSERT (gl_list_node_value (list3, gl_list_previous_node (list3, node3)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
319 == gl_list_get_at (list2, index - 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
320 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
321 if (index + 1 < gl_list_size (list1)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
322 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
323 ASSERT (gl_list_node_value (list1, gl_list_next_node (list1, node1)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
324 == gl_list_get_at (list1, index + 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
325 ASSERT (gl_list_node_value (list2, gl_list_next_node (list3, node3)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
326 == gl_list_get_at (list2, index + 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
327 ASSERT (gl_list_node_value (list3, gl_list_next_node (list3, node3)) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
328 == gl_list_get_at (list2, index + 1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
329 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
330 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
331 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
332 case 7: case 8: /* remove 1 element */ |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
333 if (gl_list_size (list1) > 0) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
334 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
335 size_t n = gl_list_size (list1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
336 const char *obj = gl_list_get_at (list1, RANDOM (n)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
337 gl_list_node_t node1, node2, node3; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
338 node1 = gl_list_search (list1, obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
339 node2 = gl_list_search (list2, obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
340 node3 = gl_list_search (list3, obj); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
341 ASSERT (node1 != NULL); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
342 ASSERT (node2 != NULL); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
343 ASSERT (node3 != NULL); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
344 ASSERT (gl_list_remove_node (list1, node1)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
345 ASSERT (gl_list_remove_node (list2, node2)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
346 ASSERT (gl_list_remove_node (list3, node3)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
347 ASSERT (gl_list_size (list1) == n - 1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
348 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
349 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
350 case 9: case 10: /* remove 1 element */ |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
351 if (gl_list_size (list1) > 0) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
352 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
353 size_t n = gl_list_size (list1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
354 size_t index = RANDOM (n); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
355 ASSERT (gl_list_remove_at (list1, index)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
356 ASSERT (gl_list_remove_at (list2, index)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
357 ASSERT (gl_list_remove_at (list3, index)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
358 ASSERT (gl_list_size (list1) == n - 1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
359 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
360 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
361 case 11: case 12: /* remove 1 element */ |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
362 if (gl_list_size (list1) > 0) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
363 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
364 size_t n = gl_list_size (list1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
365 const char *obj = gl_list_get_at (list1, RANDOM (n)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
366 ASSERT (gl_list_remove (list1, obj)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
367 ASSERT (gl_list_remove (list2, obj)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
368 ASSERT (gl_list_remove (list3, obj)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
369 ASSERT (gl_list_size (list1) == n - 1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
370 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
371 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
372 case 13: |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
373 if (gl_list_size (list1) > 0) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
374 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
375 size_t n = gl_list_size (list1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
376 const char *obj = "xyzzy"; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
377 ASSERT (!gl_list_remove (list1, obj)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
378 ASSERT (!gl_list_remove (list2, obj)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
379 ASSERT (!gl_list_remove (list3, obj)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
380 ASSERT (gl_list_size (list1) == n); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
381 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
382 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
383 case 14: |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
384 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
385 size_t n = gl_list_size (list1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
386 gl_list_iterator_t iter1, iter2, iter3; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
387 const void *elt; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
388 iter1 = gl_list_iterator (list1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
389 iter2 = gl_list_iterator (list2); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
390 iter3 = gl_list_iterator (list3); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
391 for (i = 0; i < n; i++) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
392 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
393 ASSERT (gl_list_iterator_next (&iter1, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
394 ASSERT (gl_list_get_at (list1, i) == elt); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
395 ASSERT (gl_list_iterator_next (&iter2, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
396 ASSERT (gl_list_get_at (list2, i) == elt); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
397 ASSERT (gl_list_iterator_next (&iter3, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
398 ASSERT (gl_list_get_at (list3, i) == elt); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
399 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
400 ASSERT (!gl_list_iterator_next (&iter1, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
401 ASSERT (!gl_list_iterator_next (&iter2, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
402 ASSERT (!gl_list_iterator_next (&iter3, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
403 gl_list_iterator_free (&iter1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
404 gl_list_iterator_free (&iter2); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
405 gl_list_iterator_free (&iter3); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
406 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
407 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
408 case 15: |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
409 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
410 size_t end = RANDOM (gl_list_size (list1) + 1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
411 size_t start = RANDOM (end + 1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
412 gl_list_iterator_t iter1, iter2, iter3; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
413 const void *elt; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
414 iter1 = gl_list_iterator_from_to (list1, start, end); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
415 iter2 = gl_list_iterator_from_to (list2, start, end); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
416 iter3 = gl_list_iterator_from_to (list3, start, end); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
417 for (i = start; i < end; i++) |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
418 { |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
419 ASSERT (gl_list_iterator_next (&iter1, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
420 ASSERT (gl_list_get_at (list1, i) == elt); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
421 ASSERT (gl_list_iterator_next (&iter2, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
422 ASSERT (gl_list_get_at (list2, i) == elt); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
423 ASSERT (gl_list_iterator_next (&iter3, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
424 ASSERT (gl_list_get_at (list3, i) == elt); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
425 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
426 ASSERT (!gl_list_iterator_next (&iter1, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
427 ASSERT (!gl_list_iterator_next (&iter2, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
428 ASSERT (!gl_list_iterator_next (&iter3, &elt, NULL)); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
429 gl_list_iterator_free (&iter1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
430 gl_list_iterator_free (&iter2); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
431 gl_list_iterator_free (&iter3); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
432 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
433 break; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
434 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
435 check_all (list1, list2, list3); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
436 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
437 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
438 gl_list_free (list1); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
439 gl_list_free (list2); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
440 gl_list_free (list3); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
441 free (contents); |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
442 } |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
443 |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
444 return 0; |
0bc4f2ff0eae
Sequential list data type implemented by a hash table with a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
445 } |