1447
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
1434
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#LinkedListTest
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'tests-Regression-Collections'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!LinkedListTest methodsFor:'Testing'!
|
|
14 |
|
|
15 |
testBasic1
|
|
16 |
|
|
17 |
|l|
|
|
18 |
|
|
19 |
l := LinkedList new.
|
|
20 |
self assert:l isEmpty.
|
|
21 |
self assert:l size == 0.
|
|
22 |
self assert:l notEmpty not.
|
|
23 |
|
|
24 |
l add:1.
|
|
25 |
self assert:l notEmpty.
|
|
26 |
self assert:l size == 1.
|
|
27 |
self assert:l isEmpty not.
|
|
28 |
|
|
29 |
l add:2.
|
|
30 |
self assert:l size == 2.
|
1447
|
31 |
|
1434
|
32 |
"
|
1447
|
33 |
self new testBasic1
|
1434
|
34 |
"
|
|
35 |
!
|
|
36 |
|
|
37 |
testIndexOf
|
|
38 |
"value comparing (used to work with links only, in previous versions; now works with values also)"
|
1447
|
39 |
|
1434
|
40 |
|l one two three four five|
|
|
41 |
|
|
42 |
one := 'one'.
|
|
43 |
two := 'two'.
|
|
44 |
three := 'three'.
|
|
45 |
four := 'four'.
|
|
46 |
five := 'five'.
|
|
47 |
|
|
48 |
l := LinkedList new.
|
|
49 |
l add:one.
|
|
50 |
l add:two.
|
|
51 |
l add:three.
|
|
52 |
l add:four.
|
1447
|
53 |
|
1434
|
54 |
self assert:l notEmpty.
|
|
55 |
self assert:l size == 4.
|
|
56 |
|
|
57 |
self assert:(l indexOf:one copy) == 1.
|
|
58 |
self assert:(l indexOf:two copy) == 2.
|
|
59 |
self assert:(l indexOf:three copy) == 3.
|
|
60 |
self assert:(l indexOf:four copy) == 4.
|
|
61 |
self assert:(l indexOf:five copy) == 0.
|
|
62 |
|
|
63 |
self assert:(l identityIndexOf:one) == 1.
|
|
64 |
self assert:(l identityIndexOf:two) == 2.
|
|
65 |
self assert:(l identityIndexOf:three) == 3.
|
|
66 |
self assert:(l identityIndexOf:four) == 4.
|
|
67 |
self assert:(l identityIndexOf:five) == 0.
|
1447
|
68 |
|
1434
|
69 |
self assert:(l identityIndexOf:one copy) == 0.
|
|
70 |
self assert:(l identityIndexOf:two copy) == 0.
|
|
71 |
self assert:(l identityIndexOf:three copy) == 0.
|
|
72 |
self assert:(l identityIndexOf:four copy) == 0.
|
|
73 |
|
|
74 |
"
|
1447
|
75 |
self new testBasic1
|
1434
|
76 |
"
|
|
77 |
!
|
|
78 |
|
|
79 |
testRemove
|
|
80 |
"removing (used to work with links only, in previous versions; now works with values also)"
|
1447
|
81 |
|
1434
|
82 |
|l one two three four five e1 e2|
|
|
83 |
|
|
84 |
one := 'one'.
|
|
85 |
two := 'two'.
|
|
86 |
three := 'three'.
|
|
87 |
four := 'four'.
|
|
88 |
five := 'five'.
|
|
89 |
|
|
90 |
l := LinkedList new.
|
|
91 |
l add:one.
|
|
92 |
l add:two.
|
|
93 |
l add:three.
|
|
94 |
l add:four.
|
1447
|
95 |
|
1434
|
96 |
self assert:l notEmpty.
|
|
97 |
self assert:l size == 4.
|
|
98 |
|
|
99 |
e1 := l remove:'one'.
|
|
100 |
self assert:l size == 3.
|
|
101 |
self assert:e1 = 'one'.
|
1447
|
102 |
|
1434
|
103 |
e2 := l remove:'one' ifAbsent:nil.
|
|
104 |
self assert:e2 isNil.
|
|
105 |
self assert:l size == 3.
|
1447
|
106 |
|
1434
|
107 |
e1 := l removeIdentical:two.
|
|
108 |
self assert:l size == 2.
|
|
109 |
self assert:e1 = 'two'.
|
|
110 |
self assert:e1 == two.
|
|
111 |
|
|
112 |
e2 := l removeIdentical:'three' copy ifAbsent:nil.
|
|
113 |
self assert:e2 isNil.
|
|
114 |
|
|
115 |
"
|
1447
|
116 |
self new testRemove
|
1434
|
117 |
"
|
|
118 |
! !
|
|
119 |
|
|
120 |
!LinkedListTest class methodsFor:'documentation'!
|
|
121 |
|
|
122 |
version
|
|
123 |
^ '$Header$'
|
|
124 |
!
|
|
125 |
|
|
126 |
version_CVS
|
|
127 |
^ '$Header$'
|
|
128 |
! !
|
|
129 |
|