171
|
1 |
"{ Package: 'exept:regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#QueueTest
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Tests-Regression'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!QueueTest methodsFor:'Testing'!
|
|
14 |
|
|
15 |
testBasic1
|
|
16 |
|
|
17 |
|q el|
|
|
18 |
|
|
19 |
q := Queue new:5.
|
|
20 |
self assert:q isEmpty.
|
|
21 |
self assert:q size == 0.
|
|
22 |
q nextPut:1.
|
|
23 |
self assert:q notEmpty.
|
|
24 |
self assert:q size == 1.
|
|
25 |
q nextPut:2.
|
|
26 |
self assert:q notEmpty.
|
|
27 |
self assert:q size == 2.
|
|
28 |
el := q next.
|
|
29 |
self assert:q notEmpty.
|
|
30 |
self assert:q size == 1.
|
|
31 |
self assert:(el==1).
|
|
32 |
el := q next.
|
|
33 |
self assert:q isEmpty.
|
|
34 |
self assert:q size == 0.
|
|
35 |
self assert:(el==2).
|
|
36 |
|
|
37 |
"
|
|
38 |
self new testBasic1
|
|
39 |
"
|
|
40 |
!
|
|
41 |
|
|
42 |
testBasic2
|
|
43 |
|
|
44 |
|q el|
|
|
45 |
|
|
46 |
q := Queue new:5.
|
|
47 |
self assert:q isEmpty.
|
|
48 |
self assert:q size == 0.
|
|
49 |
q nextPut:1.
|
|
50 |
q nextPut:2.
|
|
51 |
q nextPut:3.
|
|
52 |
q nextPut:4.
|
|
53 |
q nextPut:5.
|
|
54 |
el := q next.
|
|
55 |
self assert:(el==1).
|
|
56 |
el := q next.
|
|
57 |
self assert:(el==2).
|
|
58 |
el := q next.
|
|
59 |
self assert:(el==3).
|
|
60 |
el := q next.
|
|
61 |
self assert:(el==4).
|
|
62 |
el := q next.
|
|
63 |
self assert:(el==5).
|
|
64 |
|
|
65 |
"
|
|
66 |
self new testBasic2
|
|
67 |
"
|
|
68 |
!
|
|
69 |
|
|
70 |
testBasic3
|
|
71 |
|
|
72 |
|q el|
|
|
73 |
|
|
74 |
q := Queue new:5.
|
|
75 |
self assert:q isEmpty.
|
|
76 |
self assert:q size == 0.
|
|
77 |
q nextPut:1.
|
|
78 |
q nextPut:2.
|
|
79 |
q nextPut:3.
|
|
80 |
q nextPut:4.
|
|
81 |
q nextPut:5.
|
|
82 |
self should:[q nextPut:6] raise:Error.
|
|
83 |
el := q next.
|
|
84 |
self assert:(el==1).
|
|
85 |
el := q next.
|
|
86 |
self assert:(el==2).
|
|
87 |
el := q next.
|
|
88 |
self assert:(el==3).
|
|
89 |
el := q next.
|
|
90 |
self assert:(el==4).
|
|
91 |
el := q next.
|
|
92 |
self assert:(el==5).
|
|
93 |
|
|
94 |
"
|
|
95 |
self new testBasic3
|
|
96 |
"
|
|
97 |
!
|
|
98 |
|
|
99 |
testBasic4
|
|
100 |
|
|
101 |
|q el|
|
|
102 |
|
|
103 |
q := Queue new:5.
|
|
104 |
self assert:q isEmpty.
|
|
105 |
self assert:q size == 0.
|
|
106 |
q nextPut:1.
|
|
107 |
q nextPutFirst:2.
|
|
108 |
q nextPutFirst:3.
|
|
109 |
q nextPutFirst:4.
|
|
110 |
q nextPutFirst:5.
|
|
111 |
self should:[q nextPutFirst:6] raise:Error.
|
|
112 |
el := q next.
|
|
113 |
self assert:(el==5).
|
|
114 |
el := q next.
|
|
115 |
self assert:(el==4).
|
|
116 |
el := q next.
|
|
117 |
self assert:(el==3).
|
|
118 |
el := q next.
|
|
119 |
self assert:(el==2).
|
|
120 |
el := q next.
|
|
121 |
self assert:(el==1).
|
|
122 |
|
|
123 |
"
|
|
124 |
self new testBasic4
|
|
125 |
"
|
|
126 |
!
|
|
127 |
|
|
128 |
testBasic5
|
|
129 |
|
|
130 |
|q el|
|
|
131 |
|
|
132 |
q := Queue new:5.
|
|
133 |
self assert:q isEmpty.
|
|
134 |
self assert:q size == 0.
|
|
135 |
q nextPutFirst:1.
|
|
136 |
q nextPutFirst:2.
|
|
137 |
q nextPutFirst:3.
|
|
138 |
el := q next.
|
|
139 |
self assert:(el==3).
|
|
140 |
el := q next.
|
|
141 |
self assert:(el==2).
|
|
142 |
el := q next.
|
|
143 |
self assert:(el==1).
|
|
144 |
|
|
145 |
"
|
|
146 |
self new testBasic5
|
|
147 |
"
|
|
148 |
!
|
|
149 |
|
|
150 |
testRemoveAll
|
|
151 |
0 to:10 do:[:i|
|
|
152 |
self removeAllSize:10 fill:i.
|
|
153 |
].
|
|
154 |
! !
|
|
155 |
|
|
156 |
!QueueTest methodsFor:'helpers'!
|
|
157 |
|
|
158 |
removeAllSize:size fill:fill
|
|
159 |
|
|
160 |
|q|
|
|
161 |
|
|
162 |
q := Queue new:size.
|
|
163 |
|
|
164 |
1 to:fill do:[:i|
|
|
165 |
q nextPut:i.
|
|
166 |
].
|
|
167 |
q removeAll.
|
|
168 |
self assert:q isEmpty.
|
|
169 |
! !
|
|
170 |
|
|
171 |
!QueueTest class methodsFor:'documentation'!
|
|
172 |
|
|
173 |
version
|
|
174 |
^ '$Header$'
|
|
175 |
! !
|