1 /*
2 * Copyright 2001-2004 Brandon Long
3 * All Rights Reserved.
4 *
5 * ClearSilver Templating System
6 *
7 * This code is made available under the terms of the ClearSilver License.
8 * http://www.clearsilver.net/license.hdf
9 *
10 */
11
12 /*
13 * Tests for ulist library
14 */
15
16 #include "util/neo_misc.h"
17 #include "util/neo_err.h"
18 #include "util/ulist.h"
19
TestIntegerStorage()20 NEOERR *TestIntegerStorage() {
21 NEOERR *err;
22 ULIST *arr;
23 int x;
24
25 // Simple append test
26 err = uListInit(&arr, 100, 0);
27 if (err) return nerr_pass(err);
28 for (x = 0; x < 1000; x++) {
29 err = uListAppend(arr, (void *)x);
30 if (err) return nerr_pass(err);
31 }
32
33 for (x = 0; x < 1000; x++) {
34 int y;
35
36 err = uListGet(arr, x, (void *)&y);
37 if (err) return nerr_pass(err);
38 if (x != y) {
39 return nerr_raise(NERR_ASSERT,
40 "Value returned didn't match value stored: Got %d, Expected %d",
41 y, x);
42 }
43 }
44
45 return STATUS_OK;
46 }
47
48
main(int argc,char * argv[])49 int main(int argc, char *argv[]) {
50 NEOERR *err;
51
52 nerr_init();
53
54 err = TestIntegerStorage();
55 if (err) {
56 nerr_log_error(err);
57 printf("FAIL\n");
58 return -1;
59 }
60 printf("PASS\n");
61 return 0;
62 }
63