Mercurial > hg > octave-shane > gnulib-hg
annotate tests/test-rbtree_list.c @ 17622:71e733c62cee
savedir: add sorting arg to savedir, streamsavedir; remove fdsavedir
Patch based on an idea by Dick Streefland in
<https://savannah.gnu.org/patch/?7892>.
* NEWS: Document this.
* lib/savedir.c (NAME_SIZE_DEFAULT): Remove.
(direntry_t, comparison_function): New types.
(direntry_cmp_name): New function.
(direntry_cmp_inode) [D_INO_IN_DIRENT]: New function.
(streamsavedir, savedir): New arg OPTION.
(streamsavedir): Simplify memory allocation.
(fdsavedir): Remove.
* lib/savedir.h (enum savedir_option): New type.
(streamsavedir, savedir): New arg OPTION.
(fdsavedir): Remove.
author | Sergey Poznyakoff <gray@gnu.org.ua> |
---|---|
date | Thu, 13 Feb 2014 22:01:39 +0200 |
parents | 344018b6e5d7 |
children |
rev | line source |
---|---|
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of sequential list data type implementation. |
17587 | 2 Copyright (C) 2006-2014 Free Software Foundation, Inc. |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 Written by Bruno Haible <bruno@clisp.org>, 2006. |
9ccb96800d02
Sequential list data type implemented by 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 |
6980
9ccb96800d02
Sequential list data type implemented by 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. |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 |
9ccb96800d02
Sequential list data type implemented by 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/>. */ |
6980
9ccb96800d02
Sequential list data type implemented by 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> |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 |
8298
0afb48f6e566
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6980
diff
changeset
|
20 #include "gl_rbtree_list.h" |
0afb48f6e566
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6980
diff
changeset
|
21 |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 #include <stdlib.h> |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #include "gl_array_list.h" |
8298
0afb48f6e566
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6980
diff
changeset
|
25 #include "progname.h" |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12445
diff
changeset
|
26 #include "macros.h" |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 extern void gl_rbtree_list_check_invariants (gl_list_t list); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 static const char *objects[15] = |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o" |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 }; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 #define RANDOM(n) (rand () % (n)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 #define RANDOM_OBJECT() objects[RANDOM (SIZEOF (objects))] |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 static void |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 check_equals (gl_list_t list1, gl_list_t list2) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 size_t n, i; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 n = gl_list_size (list1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 ASSERT (n == gl_list_size (list2)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 for (i = 0; i < n; i++) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 ASSERT (gl_list_get_at (list1, i) == gl_list_get_at (list2, i)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 static void |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 check_all (gl_list_t list1, gl_list_t list2, gl_list_t list3) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 gl_rbtree_list_check_invariants (list2); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 gl_rbtree_list_check_invariants (list3); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 check_equals (list1, list2); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 check_equals (list1, list3); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 int |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 main (int argc, char *argv[]) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 gl_list_t list1, list2, list3; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 |
8298
0afb48f6e566
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6980
diff
changeset
|
65 set_program_name (argv[0]); |
0afb48f6e566
Avoid link error due to program_name.
Bruno Haible <bruno@clisp.org>
parents:
6980
diff
changeset
|
66 |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 /* Allow the user to provide a non-default random seed on the command line. */ |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 if (argc > 1) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 srand (atoi (argv[1])); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 size_t initial_size = RANDOM (50); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 const void **contents = |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 (const void **) malloc (initial_size * sizeof (const void *)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 size_t i; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
76 unsigned int repeat; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
77 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
78 for (i = 0; i < initial_size; i++) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
79 contents[i] = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
80 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
81 /* Create list1. */ |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
82 list1 = gl_list_nx_create (GL_ARRAY_LIST, NULL, NULL, NULL, true, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
83 initial_size, contents); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
84 ASSERT (list1 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
85 /* Create list2. */ |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
86 list2 = gl_list_nx_create_empty (GL_RBTREE_LIST, NULL, NULL, NULL, true); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
87 ASSERT (list2 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
88 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
|
89 ASSERT (gl_list_nx_add_last (list2, contents[i]) != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
90 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
91 /* Create list3. */ |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
92 list3 = gl_list_nx_create (GL_RBTREE_LIST, NULL, NULL, NULL, true, |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
93 initial_size, contents); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
94 ASSERT (list3 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
95 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
96 check_all (list1, list2, list3); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
97 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
98 for (repeat = 0; repeat < 10000; repeat++) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
99 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
100 unsigned int operation = RANDOM (16); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
101 switch (operation) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
102 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
103 case 0: |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
104 if (gl_list_size (list1) > 0) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
105 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
106 size_t index = RANDOM (gl_list_size (list1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
107 const char *obj = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
108 gl_list_node_t node1, node2, node3; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
109 |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
110 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
|
111 ASSERT (node1 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
112 ASSERT (gl_list_get_at (list1, index) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
113 ASSERT (gl_list_node_value (list1, node1) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
114 |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
115 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
|
116 ASSERT (node2 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
117 ASSERT (gl_list_get_at (list2, index) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
118 ASSERT (gl_list_node_value (list2, node2) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
119 |
12445
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
120 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
|
121 ASSERT (node3 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
122 ASSERT (gl_list_get_at (list3, index) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
123 ASSERT (gl_list_node_value (list3, node3) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
124 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
125 if (index > 0) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
126 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
127 ASSERT (gl_list_node_value (list1, gl_list_previous_node (list1, node1)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
128 == gl_list_get_at (list1, index - 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
129 ASSERT (gl_list_node_value (list2, gl_list_previous_node (list3, node3)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
130 == gl_list_get_at (list2, index - 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
131 ASSERT (gl_list_node_value (list3, gl_list_previous_node (list3, node3)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
132 == gl_list_get_at (list2, index - 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
133 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
134 if (index + 1 < gl_list_size (list1)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
135 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
136 ASSERT (gl_list_node_value (list1, gl_list_next_node (list1, node1)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
137 == gl_list_get_at (list1, index + 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
138 ASSERT (gl_list_node_value (list2, gl_list_next_node (list3, node3)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
139 == gl_list_get_at (list2, index + 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
140 ASSERT (gl_list_node_value (list3, gl_list_next_node (list3, node3)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
141 == gl_list_get_at (list2, index + 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
142 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
143 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
144 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
145 case 1: |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
146 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
147 const char *obj = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
148 gl_list_node_t node1, node2, node3; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
149 node1 = gl_list_search (list1, obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
150 node2 = gl_list_search (list2, obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
151 node3 = gl_list_search (list3, obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
152 if (node1 == NULL) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
153 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
154 ASSERT (node2 == NULL); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
155 ASSERT (node3 == NULL); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
156 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
157 else |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
158 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
159 ASSERT (node2 != NULL); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
160 ASSERT (node3 != NULL); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
161 ASSERT (gl_list_node_value (list1, node1) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
162 ASSERT (gl_list_node_value (list2, node2) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
163 ASSERT (gl_list_node_value (list3, node3) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
164 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
165 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
166 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
167 case 2: |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
168 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
169 const char *obj = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
170 size_t index1, index2, index3; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
171 index1 = gl_list_indexof (list1, obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
172 index2 = gl_list_indexof (list2, obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
173 index3 = gl_list_indexof (list3, obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
174 if (index1 == (size_t)(-1)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
175 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
176 ASSERT (index2 == (size_t)(-1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
177 ASSERT (index3 == (size_t)(-1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
178 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
179 else |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
180 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
181 ASSERT (index2 != (size_t)(-1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
182 ASSERT (index3 != (size_t)(-1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
183 ASSERT (gl_list_get_at (list1, index1) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
184 ASSERT (gl_list_get_at (list2, index2) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
185 ASSERT (gl_list_get_at (list3, index3) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
186 ASSERT (index2 == index1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
187 ASSERT (index3 == index1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
188 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
189 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
190 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
191 case 3: /* add 1 element */ |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
192 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
193 const char *obj = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
194 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
|
195 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
|
196 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
197 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
|
198 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
199 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
|
200 ASSERT (node3 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
201 ASSERT (gl_list_node_value (list1, node1) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
202 ASSERT (gl_list_node_value (list2, node2) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
203 ASSERT (gl_list_node_value (list3, node3) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
204 ASSERT (gl_list_get_at (list1, 0) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
205 ASSERT (gl_list_get_at (list2, 0) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
206 ASSERT (gl_list_get_at (list3, 0) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
207 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
208 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
209 case 4: /* add 1 element */ |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
210 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
211 const char *obj = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
212 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
|
213 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
|
214 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
215 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
|
216 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
217 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
|
218 ASSERT (node3 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
219 ASSERT (gl_list_node_value (list1, node1) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
220 ASSERT (gl_list_node_value (list2, node2) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
221 ASSERT (gl_list_node_value (list3, node3) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
222 ASSERT (gl_list_get_at (list1, gl_list_size (list1) - 1) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
223 ASSERT (gl_list_get_at (list2, gl_list_size (list2) - 1) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
224 ASSERT (gl_list_get_at (list3, gl_list_size (list3) - 1) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
225 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
226 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
227 case 5: /* add 3 elements */ |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
228 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
229 const char *obj0 = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
230 const char *obj1 = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
231 const char *obj2 = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
232 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
|
233 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
|
234 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
235 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
|
236 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
237 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
|
238 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
239 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
|
240 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
241 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
|
242 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
243 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
|
244 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
245 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
|
246 ASSERT (node3 != 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_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
|
248 ASSERT (node3 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
249 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
|
250 ASSERT (node3 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
251 ASSERT (gl_list_node_value (list1, node1) == obj1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
252 ASSERT (gl_list_node_value (list2, node2) == obj1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
253 ASSERT (gl_list_node_value (list3, node3) == obj1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
254 ASSERT (gl_list_get_at (list1, 0) == obj0); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
255 ASSERT (gl_list_get_at (list1, 1) == obj1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
256 ASSERT (gl_list_get_at (list1, 2) == obj2); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
257 ASSERT (gl_list_get_at (list2, 0) == obj0); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
258 ASSERT (gl_list_get_at (list2, 1) == obj1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
259 ASSERT (gl_list_get_at (list2, 2) == obj2); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
260 ASSERT (gl_list_get_at (list3, 0) == obj0); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
261 ASSERT (gl_list_get_at (list3, 1) == obj1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
262 ASSERT (gl_list_get_at (list3, 2) == obj2); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
263 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
264 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
265 case 6: /* add 1 element */ |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
266 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
267 size_t index = RANDOM (gl_list_size (list1) + 1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
268 const char *obj = RANDOM_OBJECT (); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
269 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
|
270 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
|
271 ASSERT (node1 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
272 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
|
273 ASSERT (node2 != NULL); |
a8c91b846640
Move the malloc checking from module 'list' to new module 'xlist'.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
274 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
|
275 ASSERT (node3 != NULL); |
6980
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
276 ASSERT (gl_list_get_at (list1, index) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
277 ASSERT (gl_list_node_value (list1, node1) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
278 ASSERT (gl_list_get_at (list2, index) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
279 ASSERT (gl_list_node_value (list2, node2) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
280 ASSERT (gl_list_get_at (list3, index) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
281 ASSERT (gl_list_node_value (list3, node3) == obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
282 if (index > 0) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
283 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
284 ASSERT (gl_list_node_value (list1, gl_list_previous_node (list1, node1)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
285 == gl_list_get_at (list1, index - 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
286 ASSERT (gl_list_node_value (list2, gl_list_previous_node (list3, node3)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
287 == gl_list_get_at (list2, index - 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
288 ASSERT (gl_list_node_value (list3, gl_list_previous_node (list3, node3)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
289 == gl_list_get_at (list2, index - 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
290 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
291 if (index + 1 < gl_list_size (list1)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
292 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
293 ASSERT (gl_list_node_value (list1, gl_list_next_node (list1, node1)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
294 == gl_list_get_at (list1, index + 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
295 ASSERT (gl_list_node_value (list2, gl_list_next_node (list3, node3)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
296 == gl_list_get_at (list2, index + 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
297 ASSERT (gl_list_node_value (list3, gl_list_next_node (list3, node3)) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
298 == gl_list_get_at (list2, index + 1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
299 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
300 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
301 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
302 case 7: case 8: /* remove 1 element */ |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
303 if (gl_list_size (list1) > 0) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
304 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
305 size_t n = gl_list_size (list1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
306 const char *obj = gl_list_get_at (list1, RANDOM (n)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
307 gl_list_node_t node1, node2, node3; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
308 node1 = gl_list_search (list1, obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
309 node2 = gl_list_search (list2, obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
310 node3 = gl_list_search (list3, obj); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
311 ASSERT (node1 != NULL); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
312 ASSERT (node2 != NULL); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
313 ASSERT (node3 != NULL); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
314 ASSERT (gl_list_remove_node (list1, node1)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
315 ASSERT (gl_list_remove_node (list2, node2)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
316 ASSERT (gl_list_remove_node (list3, node3)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
317 ASSERT (gl_list_size (list1) == n - 1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
318 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
319 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
320 case 9: case 10: /* remove 1 element */ |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
321 if (gl_list_size (list1) > 0) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
322 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
323 size_t n = gl_list_size (list1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
324 size_t index = RANDOM (n); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
325 ASSERT (gl_list_remove_at (list1, index)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
326 ASSERT (gl_list_remove_at (list2, index)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
327 ASSERT (gl_list_remove_at (list3, index)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
328 ASSERT (gl_list_size (list1) == n - 1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
329 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
330 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
331 case 11: case 12: /* remove 1 element */ |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
332 if (gl_list_size (list1) > 0) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
333 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
334 size_t n = gl_list_size (list1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
335 const char *obj = gl_list_get_at (list1, RANDOM (n)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
336 ASSERT (gl_list_remove (list1, obj)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
337 ASSERT (gl_list_remove (list2, obj)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
338 ASSERT (gl_list_remove (list3, obj)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
339 ASSERT (gl_list_size (list1) == n - 1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
340 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
341 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
342 case 13: |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
343 if (gl_list_size (list1) > 0) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
344 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
345 size_t n = gl_list_size (list1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
346 const char *obj = "xyzzy"; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
347 ASSERT (!gl_list_remove (list1, obj)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
348 ASSERT (!gl_list_remove (list2, obj)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
349 ASSERT (!gl_list_remove (list3, obj)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
350 ASSERT (gl_list_size (list1) == n); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
351 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
352 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
353 case 14: |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
354 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
355 size_t n = gl_list_size (list1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
356 gl_list_iterator_t iter1, iter2, iter3; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
357 const void *elt; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
358 iter1 = gl_list_iterator (list1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
359 iter2 = gl_list_iterator (list2); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
360 iter3 = gl_list_iterator (list3); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
361 for (i = 0; i < n; i++) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
362 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
363 ASSERT (gl_list_iterator_next (&iter1, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
364 ASSERT (gl_list_get_at (list1, i) == elt); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
365 ASSERT (gl_list_iterator_next (&iter2, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
366 ASSERT (gl_list_get_at (list2, i) == elt); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
367 ASSERT (gl_list_iterator_next (&iter3, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
368 ASSERT (gl_list_get_at (list3, i) == elt); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
369 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
370 ASSERT (!gl_list_iterator_next (&iter1, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
371 ASSERT (!gl_list_iterator_next (&iter2, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
372 ASSERT (!gl_list_iterator_next (&iter3, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
373 gl_list_iterator_free (&iter1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
374 gl_list_iterator_free (&iter2); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
375 gl_list_iterator_free (&iter3); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
376 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
377 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
378 case 15: |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
379 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
380 size_t end = RANDOM (gl_list_size (list1) + 1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
381 size_t start = RANDOM (end + 1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
382 gl_list_iterator_t iter1, iter2, iter3; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
383 const void *elt; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
384 iter1 = gl_list_iterator_from_to (list1, start, end); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
385 iter2 = gl_list_iterator_from_to (list2, start, end); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
386 iter3 = gl_list_iterator_from_to (list3, start, end); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
387 for (i = start; i < end; i++) |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
388 { |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
389 ASSERT (gl_list_iterator_next (&iter1, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
390 ASSERT (gl_list_get_at (list1, i) == elt); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
391 ASSERT (gl_list_iterator_next (&iter2, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
392 ASSERT (gl_list_get_at (list2, i) == elt); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
393 ASSERT (gl_list_iterator_next (&iter3, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
394 ASSERT (gl_list_get_at (list3, i) == elt); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
395 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
396 ASSERT (!gl_list_iterator_next (&iter1, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
397 ASSERT (!gl_list_iterator_next (&iter2, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
398 ASSERT (!gl_list_iterator_next (&iter3, &elt, NULL)); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
399 gl_list_iterator_free (&iter1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
400 gl_list_iterator_free (&iter2); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
401 gl_list_iterator_free (&iter3); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
402 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
403 break; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
404 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
405 check_all (list1, list2, list3); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
406 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
407 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
408 gl_list_free (list1); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
409 gl_list_free (list2); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
410 gl_list_free (list3); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
411 free (contents); |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
412 } |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
413 |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
414 return 0; |
9ccb96800d02
Sequential list data type implemented by a binary tree.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
415 } |