Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tests/cdt/tqueue.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 Dtqueue */
33
if(!(dt = dtopen(&Disc,Dtqueue)) )
34
terror("dtopen queue");
35
if((long)dtinsert(dt,1L) != 1)
36
terror("Dtqueue insert 1");
37
if((long)dtinsert(dt,3L) != 3)
38
terror("Dtqueue insert 3.1");
39
if((long)dtinsert(dt,2L) != 2)
40
terror("Dtqueue insert 2.1");
41
if((long)dtinsert(dt,3L) != 3)
42
terror("Dtqueue insert 3.2");
43
if((long)dtinsert(dt,2L) != 2)
44
terror("Dtqueue insert 2.2");
45
if((long)dtinsert(dt,3L) != 3)
46
terror("Dtqueue insert 3.3");
47
48
if((long)dtlast(dt) != 3)
49
terror("Dtqueue dtlast");
50
if((long)dtprev(dt,3L) != 2)
51
terror("Dtqueue dtprev 3.3");
52
if((long)dtprev(dt,2L) != 3)
53
terror("Dtqueue dtprev 2.2");
54
if((long)dtprev(dt,3L) != 2)
55
terror("Dtqueue dtprev 3.2");
56
if((long)dtprev(dt,2L) != 3)
57
terror("Dtqueue dtprev 2.1");
58
if((long)dtprev(dt,3L) != 1)
59
terror("Dtqueue dtprev 3.1");
60
if((long)dtprev(dt,1L) != 0)
61
terror("Dtqueue dtprev 1");
62
63
if((long)dtdelete(dt,NIL(Void_t*)) != 1)
64
terror("Dtqueue pop 1");
65
if((long)dtdelete(dt,NIL(Void_t*)) != 3)
66
terror("Dtqueue delete 3.1");
67
if((long)dtdelete(dt,NIL(Void_t*)) != 2)
68
terror("Dtqueue delete 2");
69
if((long)dtdelete(dt,NIL(Void_t*)) != 3)
70
terror("Dtqueue delete 3.2");
71
if((long)dtdelete(dt,NIL(Void_t*)) != 2)
72
terror("Dtqueue delete 2.1");
73
if((long)dtdelete(dt,NIL(Void_t*)) != 3)
74
terror("Dtqueue delete 3.3");
75
76
if(dtsize(dt) != 0)
77
terror("Dtqueue size");
78
79
texit(0);
80
}
81
82