#FEATURE by stefan
class: RegressionTests::DictionaryTest
class definition
added: #setUp
changed:
#testAddAll
#testAssociationsSelect
#testComma
#testIncludesAssociation
#testRemoveAllDeclareAll
class: RegressionTests::DictionaryTest class
May be configured to test different Dictionry implementations
--- a/RegressionTests__DictionaryTest.st Thu Aug 30 13:37:30 2018 +0200
+++ b/RegressionTests__DictionaryTest.st Fri Sep 14 17:16:02 2018 +0200
@@ -1,29 +1,42 @@
+"{ Encoding: utf8 }"
+
"{ Package: 'stx:goodies/regression' }"
"{ NameSpace: RegressionTests }"
TestCase subclass:#DictionaryTest
- instanceVariableNames:''
+ instanceVariableNames:'dictionaryClass'
classVariableNames:''
poolDictionaries:''
category:'tests-Regression-Collections'
!
+!DictionaryTest methodsFor:'initialize-release'!
+
+setUp
+ dictionaryClass := Dictionary.
+"/ dictionaryClass := SmallDictionary.
+
+ "Created: / 14-09-2018 / 16:38:30 / Stefan Vogel"
+! !
+
!DictionaryTest methodsFor:'testing'!
testAddAll
- "(self run: #testAddAll)"
+ "(self run: #testAddAll)"
- | dict1 dict2 |
- dict1 := Dictionary new.
- dict1 at: #a put:1 ; at: #b put: 2.
- dict2 := Dictionary new.
- dict2 at: #a put: 3 ; at: #c put: 4.
- dict1 addAll: dict2.
- self assert: (dict1 at: #a) = 3.
- self assert: (dict1 at: #b) = 2.
- self assert: (dict1 at: #c) = 4.
+ | dict1 dict2 |
+ dict1 := dictionaryClass new.
+ dict1 at: #a put:1 ; at: #b put: 2.
+ dict2 := dictionaryClass new.
+ dict2 at: #a put: 3 ; at: #c put: 4.
+ dict1 addAll: dict2.
+ self assert: (dict1 at: #a) = 3.
+ self assert: (dict1 at: #b) = 2.
+ self assert: (dict1 at: #c) = 4.
+
+ "Modified: / 14-09-2018 / 16:38:54 / Stefan Vogel"
!
testAssociationsSelect
@@ -32,42 +45,46 @@
| answer d|
- d := Dictionary new.
+ d := dictionaryClass new.
d at: (Array with: #hello with: #world) put: #fooBar.
d at: Smalltalk put: #'Smalltalk is the key'.
d at: #Smalltalk put: Smalltalk.
answer := d associationsSelect:
[:assoc | (assoc key == #Smalltalk) and: [assoc value == Smalltalk]].
- self should: [answer isKindOf: Dictionary].
+ self should: [answer isKindOf: dictionaryClass].
self should: [answer size == 1].
self should: [(answer at: #Smalltalk) == Smalltalk].
answer := d associationsSelect:
[:assoc | (assoc key == #NoSuchKey) and: [assoc value == #NoSuchValue]].
- self should: [answer isKindOf: Dictionary].
+ self should: [answer isKindOf: dictionaryClass].
self should: [answer size == 0]
+
+ "Modified: / 14-09-2018 / 16:39:05 / Stefan Vogel"
!
testComma
- "(self run: #testComma)"
+ "(self run: #testComma)"
- | dict1 dict2 dict3 |
- dict1 := Dictionary new.
- dict1 at: #a put:1 ; at: #b put: 2.
- dict2 := Dictionary new.
- dict2 at: #a put: 3 ; at: #c put: 4.
- dict3 := dict1, dict2.
- self assert: (dict3 at: #a) = 3.
- self assert: (dict3 at: #b) = 2.
- self assert: (dict3 at: #c) = 4.
+ | dict1 dict2 dict3 |
+ dict1 := dictionaryClass new.
+ dict1 at: #a put:1 ; at: #b put: 2.
+ dict2 := dictionaryClass new.
+ dict2 at: #a put: 3 ; at: #c put: 4.
+ dict3 := dict1, dict2.
+ self assert: (dict3 at: #a) = 3.
+ self assert: (dict3 at: #b) = 2.
+ self assert: (dict3 at: #c) = 4.
+
+ "Modified: / 14-09-2018 / 16:39:14 / Stefan Vogel"
!
testIncludesAssociation
"self debug: #testIncludesAssociation"
| d |
- d := Dictionary new
+ d := dictionaryClass new
at: #five put: 5;
at: #givemefive put: 5;
at: #six put: 6;
@@ -80,6 +97,7 @@
self assert: (d includesAssociation: (#five -> 6)) not.
"Modified: / 06-12-2016 / 14:19:15 / cg"
+ "Modified: / 14-09-2018 / 16:39:21 / Stefan Vogel"
!
testRemoveAllDeclareAll
@@ -91,7 +109,7 @@
| d copyOfIt |
- d := Dictionary new
+ d := dictionaryClass new
at: #five put: (5@5);
at: #givemefive put: (55@55);
at: #six put: (6@6);
@@ -115,6 +133,7 @@
].
"Created: / 06-02-2017 / 12:26:22 / cg"
+ "Modified: / 14-09-2018 / 16:39:28 / Stefan Vogel"
! !
!DictionaryTest class methodsFor:'documentation'!