Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tests/cdt/tlist.c
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1999-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#include "dttest.h"
21
22
Dtdisc_t Disc =
23
{ 0, sizeof(long), -1,
24
newint, NIL(Dtfree_f), compare, hashint,
25
NIL(Dtmemory_f), NIL(Dtevent_f)
26
};
27
28
tmain()
29
{
30
Dt_t* dt;
31
32
/* testing Dtlist */
33
if(!(dt = dtopen(&Disc,Dtlist)) )
34
terror("dtopen list");
35
if((long)dtinsert(dt,1L) != 1)
36
terror("Dtlist insert 1");
37
if((long)dtappend(dt,2L) != 2)
38
terror("Dtlist append 2");
39
if((long)dtappend(dt,3L) != 3)
40
terror("Dtlist append 3");
41
if((long)dtappend(dt,1L) != 1)
42
terror("Dtlist append 1");
43
if((long)dtappend(dt,2L) != 2)
44
terror("Dtlist append 2");
45
if((long)dtappend(dt,3L) != 3)
46
terror("Dtlist append 3");
47
48
if((long)dtlast(dt) != 3)
49
terror("Dtlist dtlast");
50
if((long)dtprev(dt,3L) != 2)
51
terror("Dtlist dtprev 2");
52
if((long)dtprev(dt,2L) != 1)
53
terror("Dtlist dtprev 1");
54
if((long)dtprev(dt,1L) != 3)
55
terror("Dtlist dtprev 3");
56
if((long)dtprev(dt,3L) != 2)
57
terror("Dtlist dtprev 2");
58
if((long)dtprev(dt,2L) != 1)
59
terror("Dtlist dtprev 1");
60
61
/* search to the first 3 */
62
if((long)dtfirst(dt) != 1)
63
terror("Dtlist dtfirst 1");
64
if((long)dtsearch(dt,3L) != 3)
65
terror("Dtlist search 3");
66
if((long)dtinsert(dt,4L) != 4)
67
terror("Dtlist insert 4");
68
if((long)dtnext(dt,4L) != 3)
69
terror("Dtlist next 3");
70
if((long)dtappend(dt,5L) != 5)
71
terror("Dtlist append 5");
72
73
if((long)dtfirst(dt) != 1)
74
terror("Dtlist dtfirst 1");
75
if((long)dtnext(dt,1L) != 2)
76
terror("Dtlist next 2");
77
if((long)dtnext(dt,2L) != 4)
78
terror("Dtlist next 4");
79
if((long)dtnext(dt,4L) != 3)
80
terror("Dtlist next 3");
81
if((long)dtnext(dt,3L) != 5)
82
terror("Dtlist next 5");
83
if((long)dtnext(dt,5L) != 1)
84
terror("Dtlist next 1");
85
if((long)dtnext(dt,1L) != 2)
86
terror("Dtlist next 2");
87
if((long)dtnext(dt,2L) != 3)
88
terror("Dtlist next 3");
89
90
texit(0);
91
}
92
93