initial checkin
authorClaus Gittinger <cg@exept.de>
Mon, 18 Mar 2013 22:49:15 +0100
changeset 824 5ba6b2a3c635
parent 823 452346d978c6
child 825 0b6f701daf93
initial checkin
RegressionTests__SegmentedOrderedCollectionTests.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RegressionTests__SegmentedOrderedCollectionTests.st	Mon Mar 18 22:49:15 2013 +0100
@@ -0,0 +1,174 @@
+"{ Package: 'exept:regression' }"
+
+"{ NameSpace: RegressionTests }"
+
+TestCase subclass:#SegmentedOrderedCollectionTests
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'tests-regression'
+!
+
+!SegmentedOrderedCollectionTests class methodsFor:'documentation'!
+
+documentation
+"
+    documentation to be added.
+
+    [author:]
+        cg
+
+    [instance variables:]
+
+    [class variables:]
+
+    [see also:]
+
+"
+! !
+
+!SegmentedOrderedCollectionTests methodsFor:'tests'!
+
+test01
+    |c|
+
+    c := SegmentedOrderedCollection new.
+    self assert:(c size == 0).
+    self should:[ c at: 1 ] raise:SubscriptOutOfBoundsError.
+
+    c add:10.
+    self assert:(c size == 1).
+    self assert:(c first == 10).
+    self assert:(c last == 10).
+
+    20 to:20000 by:10 do:[:each |
+        c add:each
+    ].
+    self assert:(c size == 2000).
+    self assert:(c first == 10).
+    self assert:(c last == 20000).
+
+    1 to:1000 do:[:i |
+        c removeFirst
+    ].
+    self assert:(c first == 10010).
+    self assert:(c last == 20000).
+    self assert:(c size == 1000).
+
+    self assert:(c collect:[:el | el] as:OrderedCollection) = (10010 to: 20000 by:10) asOrderedCollection.
+    self assert:(c at:1) == 10010.
+    self assert:(c at:499) == 14990.
+
+    c removeFromIndex:1 toIndex:499.
+    self assert:(c first == 15000).
+    self assert:(c last == 20000).
+    self assert:(c size == 501).
+
+    self assert:(c collect:[:el | el] as:OrderedCollection) = (15000 to: 20000 by:10) asOrderedCollection.
+
+    c addFirst:'xxx'.
+    self assert:(c first = 'xxx').
+    self assert:(c last == 20000).
+    self assert:(c size == 502).
+    self assert:( c removeFirst = 'xxx').
+
+    1 to:999 do:[:i |
+        c addFirst:i
+    ].
+    999 to:1 by:-1 do:[:i |
+        self assert:(c removeFirst == i)
+    ].
+
+    c removeFirst.
+    self assert:(c first == 15010).
+    self assert:(c last == 20000).
+    self assert:(c size == 500).
+
+    c removeLast.
+    self assert:(c first == 15010).
+    self assert:(c last == 19990).
+    self assert:(c size == 499).
+
+    c removeFromIndex:2 toIndex:498.
+    self assert:(c first == 15010).
+    self assert:(c last == 19990).
+    self assert:(c size == 2).
+
+    "
+     self run:#test01
+     self new test01
+    "
+!
+
+test02
+    |c tAdd tRemove|
+
+    tAdd := TimeDuration toRun:[
+        c := SegmentedOrderedCollection new.
+        1 to:200000 do:[:i |
+            c add:i
+        ].
+    ].
+    Transcript show:'Time to add 200000 elements to sc: '; showCR:tAdd.
+
+    tAdd := TimeDuration toRun:[
+        c := OrderedCollection new.
+        1 to:200000 do:[:i |
+            c add:i
+        ].
+    ].
+    Transcript show:'Time to add 200000 elements to oc: '; showCR:tAdd.
+
+    "/ ---------------------
+
+    c := SegmentedOrderedCollection withAll:(1 to:200000).
+    tRemove := TimeDuration toRun:[
+        1 to:200000 do:[:i |
+            c removeFirst
+        ].
+    ].
+    Transcript show:'Time to remove 200000 elements from sc: '; showCR:tRemove.
+
+    c := OrderedCollection withAll:(1 to:200000).
+    tRemove := TimeDuration toRun:[
+        1 to:200000 do:[:i |
+            c removeFirst
+        ].
+    ].
+    Transcript show:'Time to remove 200000 elements from oc: '; showCR:tRemove.
+
+    "/ ---------------------
+
+    c := SegmentedOrderedCollection withAll:(1 to:200000).
+    tRemove := TimeDuration toRun:[
+        1 to:100000 do:[:i |
+            c removeIndex:2000
+        ].
+    ].
+    Transcript show:'Time to remove 100000 elements from inside sc: '; showCR:tRemove.
+
+    c := OrderedCollection withAll:(1 to:200000).
+    tRemove := TimeDuration toRun:[
+        1 to:100000 do:[:i |
+            c removeIndex:2000
+        ].
+    ].
+    Transcript show:'Time to remove 100000 elements from inside oc: '; showCR:tRemove.
+
+
+    "
+     self run:#test02
+     self new test02
+    "
+! !
+
+!SegmentedOrderedCollectionTests class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+!
+
+version_CVS
+    ^ '$Header$'
+! !
+