Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tests/cdt/tdeque.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
long i, k;
32
33
/* testing Dtdeque */
34
if(!(dt = dtopen(&Disc,Dtdeque)) )
35
terror("dtopen deque");
36
if((long)dtinsert(dt,3L) != 3)
37
terror("Dtdeque insert 3");
38
if((long)dtappend(dt,4L) != 4)
39
terror("Dtdeque append 4");
40
if((long)dtinsert(dt,2L) != 2)
41
terror("Dtdeque insert 2");
42
if((long)dtappend(dt,5L) != 5)
43
terror("Dtdeque append 5");
44
if((long)dtinsert(dt,1L) != 1)
45
terror("Dtdeque insert 1");
46
if((long)dtappend(dt,6L) != 6)
47
terror("Dtdeque append 6");
48
49
for(k = 1, i = (long)dtfirst(dt); i != 0; i = (long)dtnext(dt,i), k += 1)
50
if(i != k)
51
terror("Unmatched elements");
52
if(k != 7)
53
terror("Bad element count");
54
55
texit(0);
56
}
57
58