class: RegressionTests::CollectionTests
authorStefan Vogel <sv@exept.de>
Wed, 24 Jun 2015 14:58:17 +0200
changeset 1282 e64a9d280572
parent 1281 cdfbc80e4791
child 1283 bb15790e8cdc
class: RegressionTests::CollectionTests added: #testSortedCollectionQueries
RegressionTests__CollectionTests.st
--- a/RegressionTests__CollectionTests.st	Thu Apr 09 13:58:24 2015 +0200
+++ b/RegressionTests__CollectionTests.st	Wed Jun 24 14:58:17 2015 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
 "{ Package: 'exept:regression' }"
 
 "{ NameSpace: RegressionTests }"
@@ -1217,6 +1215,36 @@
 "
  self basicNew testSortStability02
 "
+!
+
+testSortedCollectionQueries
+    "test a SortedCollection, where only a single attribute is used for sorting.
+     #include: failed before 2015-06-24"
+    
+    |collection|
+
+    collection := SortedCollection sortBlock:[:a :b | a key < b key ].
+    $a to:$z do:[:l | 
+        1 to:100 do:[:i | 
+            collection add:(Association key:l value:i)
+        ].
+    ].
+     
+    "/ make startIndex > 1 and endIndex < size
+    
+    collection
+        removeFirst;
+        removeLast.
+    collection 
+        keysAndValuesDo:[:eachIndex :eachElement | 
+            self assert:(collection detect:[:el | el = eachElement ]) notNil.
+            self assert:(collection includes:eachElement).
+            self assert:(collection indexOf:eachElement) = eachIndex.
+            self assert:(collection occurrencesOf:eachElement) = 1.
+            self 
+                assert:(collection 
+                        includes:(eachElement copy value:(eachElement value + 1000))) not.
+        ].
 ! !
 
 !CollectionTests methodsFor:'tests-squeak'!