824
|
1 |
"{ Package: 'exept:regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#SegmentedOrderedCollectionTests
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'tests-regression'
|
|
10 |
!
|
|
11 |
|
|
12 |
!SegmentedOrderedCollectionTests class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
documentation
|
|
15 |
"
|
|
16 |
documentation to be added.
|
|
17 |
|
|
18 |
[author:]
|
|
19 |
cg
|
|
20 |
|
|
21 |
[instance variables:]
|
|
22 |
|
|
23 |
[class variables:]
|
|
24 |
|
|
25 |
[see also:]
|
|
26 |
|
|
27 |
"
|
|
28 |
! !
|
|
29 |
|
|
30 |
!SegmentedOrderedCollectionTests methodsFor:'tests'!
|
|
31 |
|
|
32 |
test01
|
|
33 |
|c|
|
|
34 |
|
|
35 |
c := SegmentedOrderedCollection new.
|
|
36 |
self assert:(c size == 0).
|
|
37 |
self should:[ c at: 1 ] raise:SubscriptOutOfBoundsError.
|
|
38 |
|
|
39 |
c add:10.
|
|
40 |
self assert:(c size == 1).
|
|
41 |
self assert:(c first == 10).
|
|
42 |
self assert:(c last == 10).
|
|
43 |
|
|
44 |
20 to:20000 by:10 do:[:each |
|
|
45 |
c add:each
|
|
46 |
].
|
|
47 |
self assert:(c size == 2000).
|
|
48 |
self assert:(c first == 10).
|
|
49 |
self assert:(c last == 20000).
|
|
50 |
|
|
51 |
1 to:1000 do:[:i |
|
|
52 |
c removeFirst
|
|
53 |
].
|
|
54 |
self assert:(c first == 10010).
|
|
55 |
self assert:(c last == 20000).
|
|
56 |
self assert:(c size == 1000).
|
|
57 |
|
|
58 |
self assert:(c collect:[:el | el] as:OrderedCollection) = (10010 to: 20000 by:10) asOrderedCollection.
|
|
59 |
self assert:(c at:1) == 10010.
|
|
60 |
self assert:(c at:499) == 14990.
|
|
61 |
|
|
62 |
c removeFromIndex:1 toIndex:499.
|
|
63 |
self assert:(c first == 15000).
|
|
64 |
self assert:(c last == 20000).
|
|
65 |
self assert:(c size == 501).
|
|
66 |
|
|
67 |
self assert:(c collect:[:el | el] as:OrderedCollection) = (15000 to: 20000 by:10) asOrderedCollection.
|
|
68 |
|
|
69 |
c addFirst:'xxx'.
|
|
70 |
self assert:(c first = 'xxx').
|
|
71 |
self assert:(c last == 20000).
|
|
72 |
self assert:(c size == 502).
|
|
73 |
self assert:( c removeFirst = 'xxx').
|
|
74 |
|
|
75 |
1 to:999 do:[:i |
|
|
76 |
c addFirst:i
|
|
77 |
].
|
|
78 |
999 to:1 by:-1 do:[:i |
|
|
79 |
self assert:(c removeFirst == i)
|
|
80 |
].
|
|
81 |
|
|
82 |
c removeFirst.
|
|
83 |
self assert:(c first == 15010).
|
|
84 |
self assert:(c last == 20000).
|
|
85 |
self assert:(c size == 500).
|
|
86 |
|
|
87 |
c removeLast.
|
|
88 |
self assert:(c first == 15010).
|
|
89 |
self assert:(c last == 19990).
|
|
90 |
self assert:(c size == 499).
|
|
91 |
|
|
92 |
c removeFromIndex:2 toIndex:498.
|
|
93 |
self assert:(c first == 15010).
|
|
94 |
self assert:(c last == 19990).
|
|
95 |
self assert:(c size == 2).
|
|
96 |
|
|
97 |
"
|
|
98 |
self run:#test01
|
|
99 |
self new test01
|
|
100 |
"
|
|
101 |
!
|
|
102 |
|
|
103 |
test02
|
|
104 |
|c tAdd tRemove|
|
|
105 |
|
|
106 |
tAdd := TimeDuration toRun:[
|
|
107 |
c := SegmentedOrderedCollection new.
|
|
108 |
1 to:200000 do:[:i |
|
|
109 |
c add:i
|
|
110 |
].
|
|
111 |
].
|
|
112 |
Transcript show:'Time to add 200000 elements to sc: '; showCR:tAdd.
|
|
113 |
|
|
114 |
tAdd := TimeDuration toRun:[
|
|
115 |
c := OrderedCollection new.
|
|
116 |
1 to:200000 do:[:i |
|
|
117 |
c add:i
|
|
118 |
].
|
|
119 |
].
|
|
120 |
Transcript show:'Time to add 200000 elements to oc: '; showCR:tAdd.
|
|
121 |
|
|
122 |
"/ ---------------------
|
|
123 |
|
|
124 |
c := SegmentedOrderedCollection withAll:(1 to:200000).
|
|
125 |
tRemove := TimeDuration toRun:[
|
|
126 |
1 to:200000 do:[:i |
|
|
127 |
c removeFirst
|
|
128 |
].
|
|
129 |
].
|
|
130 |
Transcript show:'Time to remove 200000 elements from sc: '; showCR:tRemove.
|
|
131 |
|
|
132 |
c := OrderedCollection withAll:(1 to:200000).
|
|
133 |
tRemove := TimeDuration toRun:[
|
|
134 |
1 to:200000 do:[:i |
|
|
135 |
c removeFirst
|
|
136 |
].
|
|
137 |
].
|
|
138 |
Transcript show:'Time to remove 200000 elements from oc: '; showCR:tRemove.
|
|
139 |
|
|
140 |
"/ ---------------------
|
|
141 |
|
|
142 |
c := SegmentedOrderedCollection withAll:(1 to:200000).
|
|
143 |
tRemove := TimeDuration toRun:[
|
|
144 |
1 to:100000 do:[:i |
|
|
145 |
c removeIndex:2000
|
|
146 |
].
|
|
147 |
].
|
|
148 |
Transcript show:'Time to remove 100000 elements from inside sc: '; showCR:tRemove.
|
|
149 |
|
|
150 |
c := OrderedCollection withAll:(1 to:200000).
|
|
151 |
tRemove := TimeDuration toRun:[
|
|
152 |
1 to:100000 do:[:i |
|
|
153 |
c removeIndex:2000
|
|
154 |
].
|
|
155 |
].
|
|
156 |
Transcript show:'Time to remove 100000 elements from inside oc: '; showCR:tRemove.
|
|
157 |
|
|
158 |
|
|
159 |
"
|
|
160 |
self run:#test02
|
|
161 |
self new test02
|
|
162 |
"
|
|
163 |
! !
|
|
164 |
|
|
165 |
!SegmentedOrderedCollectionTests class methodsFor:'documentation'!
|
|
166 |
|
|
167 |
version
|
|
168 |
^ '$Header$'
|
|
169 |
!
|
|
170 |
|
|
171 |
version_CVS
|
|
172 |
^ '$Header$'
|
|
173 |
! !
|
|
174 |
|