source: trunk/src/cutest_zAVLTree.c@ 482

Last change on this file since 482 was 481, checked in by katerina, 9 years ago

Enhancements and fixes for tickets #374, #375, #376, #377, #378, and #379.

File size: 16.1 KB
RevLine 
[17]1
2#include "config_xor.h"
3
4#include <string.h>
5#include "CuTest.h"
6#include "zAVLTree.h"
7
8struct ztest {
9 char name[32];
[366]10 int iname;
[17]11};
12
13static zAVLTree * ztest_tree = NULL;
14
15static zAVLKey ztest_key (void const * arg)
16{
17 const struct ztest * sa = (const struct ztest *) arg;
18 return (zAVLKey) sa->name;
19}
20
[366]21static zAVLKey ztest_intkey(void const *item)
22{
[481]23 return (&((const struct ztest *)item)->iname);
[366]24}
25
26
[17]27static void free_node (void * inptr)
28{
29 struct ztest * ptr = (struct ztest *) inptr;
30 ptr->name[0] = '\0';
[366]31 ptr->iname = 0;
[17]32}
33
34void Test_zAVLTree(CuTest *tc) {
35 zAVLCursor cursor;
36
37 int result;
38 int counter = 0;
39
[452]40 char * str;
41
[366]42 struct ztest z1 = { "abc" , 1 };
43 struct ztest z2 = { "aac" , 2 };
44 struct ztest z3 = { "aaa1" , 3 };
45 struct ztest z4 = { "aaa3" , 4 };
46 struct ztest z5 = { "aaa2" , 5 };
47 struct ztest z6 = { "aaa6" , 6 };
48 struct ztest z7 = { "aaa5" , 7 };
49 struct ztest z8 = { "aaa4" , 8 };
[17]50
[366]51 struct ztest iz1 = { "aaa1" , 8 };
52 struct ztest iz2 = { "aaa2" , 7 };
53 struct ztest iz3 = { "aaa3" , 1 };
54 struct ztest iz4 = { "aaa4" , 3 };
55 struct ztest iz5 = { "aaa5" , 2 };
56 struct ztest iz6 = { "aaa5" , 6 };
57 struct ztest iz7 = { "aaa7" , 5 };
58 struct ztest iz8 = { "aaa8" , 4 };
59
[17]60 struct ztest * ptr;
61
62 ptr = zAVLFirst(&cursor, ztest_tree);
63 CuAssertTrue(tc, NULL == ptr);
64
[363]65 ztest_tree = zAVLAllocTree (ztest_key, zAVL_KEY_STRING);
[17]66 CuAssertPtrNotNull(tc, ztest_tree);
67
68 do {
69
70 ++counter;
71
72 result = zAVLInsert(ztest_tree, &z1);
73 CuAssertTrue(tc, 0 == result);
74 result = zAVLInsert(ztest_tree, &z2);
75 CuAssertTrue(tc, 0 == result);
76 result = zAVLInsert(ztest_tree, &z3);
77 CuAssertTrue(tc, 0 == result);
78 result = zAVLInsert(ztest_tree, &z4);
79 CuAssertTrue(tc, 0 == result);
80 result = zAVLInsert(ztest_tree, &z5);
81 CuAssertTrue(tc, 0 == result);
82 result = zAVLInsert(ztest_tree, &z6);
83 CuAssertTrue(tc, 0 == result);
84 result = zAVLInsert(ztest_tree, &z7);
85 CuAssertTrue(tc, 0 == result);
86 result = zAVLInsert(ztest_tree, &z8);
87 CuAssertTrue(tc, 0 == result);
88
89 ptr = zAVLFirst(&cursor, ztest_tree);
90 CuAssertStrEquals(tc, ptr->name, z3.name);
91 ptr = zAVLNext(&cursor);
92 CuAssertStrEquals(tc, ptr->name, z5.name);
93 ptr = zAVLNext(&cursor);
94 CuAssertStrEquals(tc, ptr->name, z4.name);
95 ptr = zAVLNext(&cursor);
96 CuAssertStrEquals(tc, ptr->name, z8.name);
97 ptr = zAVLNext(&cursor);
98 CuAssertStrEquals(tc, ptr->name, z7.name);
99 ptr = zAVLNext(&cursor);
100 CuAssertStrEquals(tc, ptr->name, z6.name);
101 ptr = zAVLNext(&cursor);
102 CuAssertStrEquals(tc, ptr->name, z2.name);
103 ptr = zAVLNext(&cursor);
104 CuAssertStrEquals(tc, ptr->name, z1.name);
105 ptr = zAVLNext(&cursor);
106 CuAssertTrue(tc, NULL == ptr);
107
108 result = zAVLInsert(ztest_tree, &z8);
109 CuAssertTrue(tc, 0 != result);
110 result = zAVLInsert(ztest_tree, &z7);
111 CuAssertTrue(tc, 0 != result);
112 result = zAVLInsert(ztest_tree, &z6);
113 CuAssertTrue(tc, 0 != result);
114 result = zAVLInsert(ztest_tree, &z5);
115 CuAssertTrue(tc, 0 != result);
116
117 ptr = zAVLSearch(ztest_tree, z1.name);
118 CuAssertStrEquals(tc, ptr->name, z1.name);
119 ptr = zAVLSearch(ztest_tree, z2.name);
120 CuAssertStrEquals(tc, ptr->name, z2.name);
121 ptr = zAVLSearch(ztest_tree, z3.name);
122 CuAssertStrEquals(tc, ptr->name, z3.name);
123 ptr = zAVLSearch(ztest_tree, z4.name);
124 CuAssertStrEquals(tc, ptr->name, z4.name);
125
126 ptr = zAVLFirst(&cursor, ztest_tree);
127 CuAssertStrEquals(tc, ptr->name, z3.name);
128 ptr = zAVLNext(&cursor);
129 CuAssertStrEquals(tc, ptr->name, z5.name);
130 ptr = zAVLNext(&cursor);
131 CuAssertStrEquals(tc, ptr->name, z4.name);
132 ptr = zAVLNext(&cursor);
133 CuAssertStrEquals(tc, ptr->name, z8.name);
134 ptr = zAVLNext(&cursor);
135 CuAssertStrEquals(tc, ptr->name, z7.name);
136 ptr = zAVLNext(&cursor);
137 CuAssertStrEquals(tc, ptr->name, z6.name);
138 ptr = zAVLNext(&cursor);
139 CuAssertStrEquals(tc, ptr->name, z2.name);
140 ptr = zAVLNext(&cursor);
141 CuAssertStrEquals(tc, ptr->name, z1.name);
142 ptr = zAVLNext(&cursor);
143 CuAssertTrue(tc, NULL == ptr);
144
145
146 ptr = zAVLSearch(ztest_tree, z5.name);
147 CuAssertStrEquals(tc, ptr->name, z5.name);
148 ptr = zAVLSearch(ztest_tree, z6.name);
149 CuAssertStrEquals(tc, ptr->name, z6.name);
150 ptr = zAVLSearch(ztest_tree, z7.name);
151 CuAssertStrEquals(tc, ptr->name, z7.name);
152 ptr = zAVLSearch(ztest_tree, z8.name);
153 CuAssertStrEquals(tc, ptr->name, z8.name);
154 ptr = zAVLSearch(ztest_tree, "foobar");
155 CuAssertTrue(tc, NULL == ptr);
156
157 result = zAVLDelete(ztest_tree, z8.name);
158 CuAssertTrue(tc, 0 == result);
159 ptr = zAVLSearch(ztest_tree, z8.name);
160 CuAssertTrue(tc, NULL == ptr);
161
162 result = zAVLDelete(ztest_tree, z3.name);
163 CuAssertTrue(tc, 0 == result);
164 ptr = zAVLSearch(ztest_tree, z3.name);
165 CuAssertTrue(tc, NULL == ptr);
166
167 result = zAVLDelete(ztest_tree, z1.name);
168 CuAssertTrue(tc, 0 == result);
169 ptr = zAVLSearch(ztest_tree, z1.name);
170 CuAssertTrue(tc, NULL == ptr);
171
172 result = zAVLInsert(ztest_tree, &z1);
173 CuAssertTrue(tc, 0 == result);
174 result = zAVLInsert(ztest_tree, &z8);
175 CuAssertTrue(tc, 0 == result);
176 result = zAVLInsert(ztest_tree, &z3);
177 CuAssertTrue(tc, 0 == result);
178
179 ptr = zAVLFirst(&cursor, ztest_tree);
180 CuAssertStrEquals(tc, ptr->name, z3.name);
181 ptr = zAVLNext(&cursor);
182 CuAssertStrEquals(tc, ptr->name, z5.name);
183 ptr = zAVLNext(&cursor);
184 CuAssertStrEquals(tc, ptr->name, z4.name);
185 ptr = zAVLNext(&cursor);
186 CuAssertStrEquals(tc, ptr->name, z8.name);
187 ptr = zAVLNext(&cursor);
188 CuAssertStrEquals(tc, ptr->name, z7.name);
189 ptr = zAVLNext(&cursor);
190 CuAssertStrEquals(tc, ptr->name, z6.name);
191 ptr = zAVLNext(&cursor);
192 CuAssertStrEquals(tc, ptr->name, z2.name);
193 ptr = zAVLNext(&cursor);
194 CuAssertStrEquals(tc, ptr->name, z1.name);
195 ptr = zAVLNext(&cursor);
196 CuAssertTrue(tc, NULL == ptr);
197
198 result = zAVLDelete(ztest_tree, z1.name);
199 CuAssertTrue(tc, 0 == result);
200 ptr = zAVLSearch(ztest_tree, z1.name);
201 CuAssertTrue(tc, NULL == ptr);
202
203 result = zAVLDelete(ztest_tree, z2.name);
204 CuAssertTrue(tc, 0 == result);
205 ptr = zAVLSearch(ztest_tree, z2.name);
206 CuAssertTrue(tc, NULL == ptr);
207
208 result = zAVLDelete(ztest_tree, z3.name);
209 CuAssertTrue(tc, 0 == result);
210 ptr = zAVLSearch(ztest_tree, z3.name);
211 CuAssertTrue(tc, NULL == ptr);
212
213 result = zAVLDelete(ztest_tree, z4.name);
214 CuAssertTrue(tc, 0 == result);
215 ptr = zAVLSearch(ztest_tree, z4.name);
216 CuAssertTrue(tc, NULL == ptr);
217
218 result = zAVLDelete(ztest_tree, z5.name);
219 CuAssertTrue(tc, 0 == result);
220 ptr = zAVLSearch(ztest_tree, z5.name);
221 CuAssertTrue(tc, NULL == ptr);
222
223 result = zAVLDelete(ztest_tree, z6.name);
224 CuAssertTrue(tc, 0 == result);
225 ptr = zAVLSearch(ztest_tree, z6.name);
226 CuAssertTrue(tc, NULL == ptr);
227
228 result = zAVLDelete(ztest_tree, z7.name);
229 CuAssertTrue(tc, 0 == result);
230 ptr = zAVLSearch(ztest_tree, z7.name);
231 CuAssertTrue(tc, NULL == ptr);
232
233 result = zAVLDelete(ztest_tree, z8.name);
234 CuAssertTrue(tc, 0 == result);
235 ptr = zAVLSearch(ztest_tree, z8.name);
236 CuAssertTrue(tc, NULL == ptr);
237
238} while (counter < 100);
239
240 result = zAVLInsert(ztest_tree, &z1);
241 CuAssertTrue(tc, 0 == result);
242 result = zAVLInsert(ztest_tree, &z2);
243 CuAssertTrue(tc, 0 == result);
244 result = zAVLInsert(ztest_tree, &z3);
245 CuAssertTrue(tc, 0 == result);
246 result = zAVLInsert(ztest_tree, &z4);
247 CuAssertTrue(tc, 0 == result);
248 result = zAVLInsert(ztest_tree, &z5);
249 CuAssertTrue(tc, 0 == result);
250 result = zAVLInsert(ztest_tree, &z6);
251 CuAssertTrue(tc, 0 == result);
252 result = zAVLInsert(ztest_tree, &z7);
253 CuAssertTrue(tc, 0 == result);
254 result = zAVLInsert(ztest_tree, &z8);
255 CuAssertTrue(tc, 0 == result);
256
257 zAVLFreeTree (ztest_tree, free_node);
258 CuAssertTrue (tc, z1.name[0] == '\0');
259 CuAssertTrue (tc, z2.name[0] == '\0');
260 CuAssertTrue (tc, z3.name[0] == '\0');
261 CuAssertTrue (tc, z4.name[0] == '\0');
262 CuAssertTrue (tc, z5.name[0] == '\0');
263 CuAssertTrue (tc, z6.name[0] == '\0');
264 CuAssertTrue (tc, z7.name[0] == '\0');
265 CuAssertTrue (tc, z8.name[0] == '\0');
[366]266
267
268 /* Numeric key here */
269
270 counter = 0;
271 ztest_tree = NULL;
272
273 ptr = zAVLFirst(&cursor, ztest_tree);
274 CuAssertTrue(tc, NULL == ptr);
275
276 ztest_tree = zAVLAllocTree (ztest_intkey, zAVL_KEY_INT);
277 CuAssertPtrNotNull(tc, ztest_tree);
278
279 do {
280
281 ++counter;
282
283 result = zAVLInsert(ztest_tree, &iz1);
284 CuAssertTrue(tc, 0 == result);
285 result = zAVLInsert(ztest_tree, &iz2);
286 CuAssertTrue(tc, 0 == result);
287 result = zAVLInsert(ztest_tree, &iz3);
288 CuAssertTrue(tc, 0 == result);
289 result = zAVLInsert(ztest_tree, &iz4);
290 CuAssertTrue(tc, 0 == result);
291 result = zAVLInsert(ztest_tree, &iz5);
292 CuAssertTrue(tc, 0 == result);
293 result = zAVLInsert(ztest_tree, &iz6);
294 CuAssertTrue(tc, 0 == result);
295 result = zAVLInsert(ztest_tree, &iz7);
296 CuAssertTrue(tc, 0 == result);
297 result = zAVLInsert(ztest_tree, &iz8);
298 CuAssertTrue(tc, 0 == result);
299
300 ptr = zAVLFirst(&cursor, ztest_tree);
301 CuAssertStrEquals(tc, ptr->name, iz3.name);
302 ptr = zAVLNext(&cursor);
303 CuAssertStrEquals(tc, ptr->name, iz5.name);
304 ptr = zAVLNext(&cursor);
305 CuAssertStrEquals(tc, ptr->name, iz4.name);
306 ptr = zAVLNext(&cursor);
307 CuAssertStrEquals(tc, ptr->name, iz8.name);
308 ptr = zAVLNext(&cursor);
309 CuAssertStrEquals(tc, ptr->name, iz7.name);
310 ptr = zAVLNext(&cursor);
311 CuAssertStrEquals(tc, ptr->name, iz6.name);
312 ptr = zAVLNext(&cursor);
313 CuAssertStrEquals(tc, ptr->name, iz2.name);
314 ptr = zAVLNext(&cursor);
315 CuAssertStrEquals(tc, ptr->name, iz1.name);
316 ptr = zAVLNext(&cursor);
317 CuAssertTrue(tc, NULL == ptr);
318
319 result = zAVLInsert(ztest_tree, &iz8);
320 CuAssertTrue(tc, 0 != result);
321 result = zAVLInsert(ztest_tree, &iz7);
322 CuAssertTrue(tc, 0 != result);
323 result = zAVLInsert(ztest_tree, &iz6);
324 CuAssertTrue(tc, 0 != result);
325 result = zAVLInsert(ztest_tree, &iz5);
326 CuAssertTrue(tc, 0 != result);
327
328 ptr = zAVLSearch(ztest_tree, &(iz1.iname));
329 CuAssertIntEquals(tc, ptr->iname, iz1.iname);
330 ptr = zAVLSearch(ztest_tree, &(iz2.iname));
331 CuAssertIntEquals(tc, ptr->iname, iz2.iname);
332 ptr = zAVLSearch(ztest_tree, &(iz3.iname));
333 CuAssertIntEquals(tc, ptr->iname, iz3.iname);
334 ptr = zAVLSearch(ztest_tree, &(iz6.iname));
335 CuAssertIntEquals(tc, ptr->iname, iz6.iname);
336 ptr = zAVLSearch(ztest_tree, &(iz4.iname));
337 CuAssertIntEquals(tc, ptr->iname, iz4.iname);
338
339 ptr = zAVLSearch(ztest_tree, &(iz2.iname));
340 CuAssertIntEquals(tc, ptr->iname, iz2.iname);
341 ptr = zAVLSearch(ztest_tree, &(iz3.iname));
342 CuAssertIntEquals(tc, ptr->iname, iz3.iname);
343 ptr = zAVLSearch(ztest_tree, &(iz7.iname));
344 CuAssertIntEquals(tc, ptr->iname, iz7.iname);
345
346 ptr = zAVLFirst(&cursor, ztest_tree);
347 CuAssertStrEquals(tc, ptr->name, iz3.name);
348 ptr = zAVLNext(&cursor);
349 CuAssertStrEquals(tc, ptr->name, iz5.name);
350 ptr = zAVLNext(&cursor);
351 CuAssertStrEquals(tc, ptr->name, iz4.name);
352 ptr = zAVLNext(&cursor);
353 CuAssertStrEquals(tc, ptr->name, iz8.name);
354 ptr = zAVLNext(&cursor);
355 CuAssertStrEquals(tc, ptr->name, iz7.name);
356 ptr = zAVLNext(&cursor);
357 CuAssertStrEquals(tc, ptr->name, iz6.name);
358 ptr = zAVLNext(&cursor);
359 CuAssertStrEquals(tc, ptr->name, iz2.name);
360 ptr = zAVLNext(&cursor);
361 CuAssertStrEquals(tc, ptr->name, iz1.name);
362 ptr = zAVLNext(&cursor);
363 CuAssertTrue(tc, NULL == ptr);
364
365
366 ptr = zAVLSearch(ztest_tree, &(iz5.iname));
367 CuAssertStrEquals(tc, ptr->name, iz5.name);
368 ptr = zAVLSearch(ztest_tree, &(iz6.iname));
369 CuAssertStrEquals(tc, ptr->name, iz6.name);
370 ptr = zAVLSearch(ztest_tree, &(iz7.iname));
371 CuAssertStrEquals(tc, ptr->name, iz7.name);
372 ptr = zAVLSearch(ztest_tree, &(iz8.iname));
373 CuAssertStrEquals(tc, ptr->name, iz8.name);
374 ptr = zAVLSearch(ztest_tree, &(z1.iname)); /* been set to 0 */
375 CuAssertTrue(tc, NULL == ptr);
376
377 result = zAVLDelete(ztest_tree, &(iz8.iname));
378 CuAssertTrue(tc, 0 == result);
379 ptr = zAVLSearch(ztest_tree, &(iz8.iname));
380 CuAssertTrue(tc, NULL == ptr);
381
382 result = zAVLDelete(ztest_tree, &(iz3.iname));
383 CuAssertTrue(tc, 0 == result);
384 ptr = zAVLSearch(ztest_tree, &(iz3.iname));
385 CuAssertTrue(tc, NULL == ptr);
386
387 result = zAVLDelete(ztest_tree, &(iz1.iname));
388 CuAssertTrue(tc, 0 == result);
389 ptr = zAVLSearch(ztest_tree, &(iz1.iname));
390 CuAssertTrue(tc, NULL == ptr);
391
392 result = zAVLInsert(ztest_tree, &iz1);
393 CuAssertTrue(tc, 0 == result);
394 result = zAVLInsert(ztest_tree, &iz8);
395 CuAssertTrue(tc, 0 == result);
396 result = zAVLInsert(ztest_tree, &iz3);
397 CuAssertTrue(tc, 0 == result);
398
399 ptr = zAVLFirst(&cursor, ztest_tree);
400 CuAssertIntEquals(tc, ptr->iname, iz3.iname);
401 ptr = zAVLNext(&cursor);
402 CuAssertStrEquals(tc, ptr->name, iz5.name);
403 ptr = zAVLNext(&cursor);
404 CuAssertStrEquals(tc, ptr->name, iz4.name);
405 ptr = zAVLNext(&cursor);
406 CuAssertIntEquals(tc, ptr->iname, iz8.iname);
407 ptr = zAVLNext(&cursor);
408 CuAssertStrEquals(tc, ptr->name, iz7.name);
409 ptr = zAVLNext(&cursor);
410 CuAssertStrEquals(tc, ptr->name, iz6.name);
411 ptr = zAVLNext(&cursor);
412 CuAssertIntEquals(tc, ptr->iname, iz2.iname);
413 ptr = zAVLNext(&cursor);
414 CuAssertStrEquals(tc, ptr->name, iz1.name);
415 ptr = zAVLNext(&cursor);
416 CuAssertTrue(tc, NULL == ptr);
417
418 result = zAVLDelete(ztest_tree, &(iz1.iname));
419 CuAssertTrue(tc, 0 == result);
420 ptr = zAVLSearch(ztest_tree, &(iz1.iname));
421 CuAssertTrue(tc, NULL == ptr);
422
423 result = zAVLDelete(ztest_tree, &(iz2.iname));
424 CuAssertTrue(tc, 0 == result);
425 ptr = zAVLSearch(ztest_tree, &(iz2.iname));
426 CuAssertTrue(tc, NULL == ptr);
427
428 result = zAVLDelete(ztest_tree, &(iz3.iname));
429 CuAssertTrue(tc, 0 == result);
430 ptr = zAVLSearch(ztest_tree, &(iz3.iname));
431 CuAssertTrue(tc, NULL == ptr);
432
433 result = zAVLDelete(ztest_tree, &(iz4.iname));
434 CuAssertTrue(tc, 0 == result);
435 ptr = zAVLSearch(ztest_tree, &(iz4.iname));
436 CuAssertTrue(tc, NULL == ptr);
437
438 result = zAVLDelete(ztest_tree, &(iz5.iname));
439 CuAssertTrue(tc, 0 == result);
440 ptr = zAVLSearch(ztest_tree, &(iz5.iname));
441 CuAssertTrue(tc, NULL == ptr);
442
443 result = zAVLDelete(ztest_tree, &(iz6.iname));
444 CuAssertTrue(tc, 0 == result);
445 ptr = zAVLSearch(ztest_tree, &(iz6.iname));
446 CuAssertTrue(tc, NULL == ptr);
447
448 result = zAVLDelete(ztest_tree, &(iz7.iname));
449 CuAssertTrue(tc, 0 == result);
450 ptr = zAVLSearch(ztest_tree, &(iz7.iname));
451 CuAssertTrue(tc, NULL == ptr);
452
453 result = zAVLDelete(ztest_tree, &(iz8.iname));
454 CuAssertTrue(tc, 0 == result);
455 ptr = zAVLSearch(ztest_tree, &(iz8.iname));
456 CuAssertTrue(tc, NULL == ptr);
457
458} while (counter < 100);
459
460 result = zAVLInsert(ztest_tree, &iz1);
461 CuAssertTrue(tc, 0 == result);
462 result = zAVLInsert(ztest_tree, &iz2);
463 CuAssertTrue(tc, 0 == result);
464 result = zAVLInsert(ztest_tree, &iz3);
465 CuAssertTrue(tc, 0 == result);
466 result = zAVLInsert(ztest_tree, &iz4);
467 CuAssertTrue(tc, 0 == result);
468 result = zAVLInsert(ztest_tree, &iz5);
469 CuAssertTrue(tc, 0 == result);
470 result = zAVLInsert(ztest_tree, &iz6);
471 CuAssertTrue(tc, 0 == result);
472 result = zAVLInsert(ztest_tree, &iz7);
473 CuAssertTrue(tc, 0 == result);
474 result = zAVLInsert(ztest_tree, &iz8);
475 CuAssertTrue(tc, 0 == result);
476
477 zAVLFreeTree (ztest_tree, free_node);
478 CuAssertTrue (tc, iz1.iname == 0);
479 CuAssertTrue (tc, iz2.iname == 0);
480 CuAssertTrue (tc, iz3.iname == 0);
481 CuAssertTrue (tc, iz4.iname == 0);
482 CuAssertTrue (tc, iz5.iname == 0);
483 CuAssertTrue (tc, iz6.iname == 0);
484 CuAssertTrue (tc, iz7.iname == 0);
485 CuAssertTrue (tc, iz8.iname == 0);
486
[452]487 ztest_tree = NULL;
488 str = strdup("foo");
489 result = zAVL_string_set(&ztest_tree, str);
490 CuAssertTrue(tc, 0 == result);
491 CuAssertPtrNotNull(tc, ztest_tree);
492 CuAssertStrEquals(tc, "foo", zAVL_string_get(ztest_tree, "foo"));
[366]493
[452]494 str = strdup("bar");
495 result = zAVL_string_set(&ztest_tree, str);
496 CuAssertTrue(tc, 0 == result);
497 CuAssertStrEquals(tc, "foo", zAVL_string_get(ztest_tree, "foo"));
498 CuAssertStrEquals(tc, "bar", zAVL_string_get(ztest_tree, "bar"));
499
500 str = strdup("balloon");
501 result = zAVL_string_set(&ztest_tree, str);
502 CuAssertTrue(tc, 0 == result);
503 CuAssertStrEquals(tc, "foo", zAVL_string_get(ztest_tree, "foo"));
504 CuAssertStrEquals(tc, "bar", zAVL_string_get(ztest_tree, "bar"));
505 CuAssertStrEquals(tc, "balloon", zAVL_string_get(ztest_tree, "balloon"));
506
507 str = zAVL_string_get(ztest_tree, "foobar");
508 CuAssertTrue(tc, str == NULL);
509 str = zAVL_string_get(ztest_tree, "");
510 CuAssertTrue(tc, str == NULL);
511 str = zAVL_string_get(ztest_tree, NULL);
512 CuAssertTrue(tc, str == NULL);
513
514 zAVL_string_reset(ztest_tree);
515 str = zAVL_string_get(ztest_tree, "foo");
516 CuAssertTrue(tc, str == NULL);
517 str = zAVL_string_get(ztest_tree, "bar");
518 CuAssertTrue(tc, str == NULL);
519 str = zAVL_string_get(ztest_tree, "balloon");
520 CuAssertTrue(tc, str == NULL);
521
[17]522}
Note: See TracBrowser for help on using the repository browser.