annotate tests/test-linkedhash_list.c @ 9084:2932e92d6e31

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