RegressionTests__DictionaryTest.st
author Claus Gittinger <cg@exept.de>
Tue, 06 Dec 2016 14:19:31 +0100
changeset 1553 5eecd405c903
parent 1547 606e915e2216
child 1564 2a4963ef3a4a
child 1572 d558d6dc7c45
permissions -rw-r--r--
#QUALITY by cg class: RegressionTests::DictionaryTest changed: #testIncludesAssociation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
     1
"{ Package: 'stx:goodies/regression' }"
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: RegressionTests }"
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
TestCase subclass:#DictionaryTest
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	instanceVariableNames:''
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	classVariableNames:''
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	poolDictionaries:''
1055
0d0b2641d00b category
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
     9
	category:'tests-Regression-Collections'
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
!DictionaryTest methodsFor:'testing'!
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
testAddAll
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	"(self run: #testAddAll)"
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
    17
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	| dict1 dict2 |
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	dict1 := Dictionary new.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
    20
	dict1 at: #a put:1 ; at: #b put: 2.
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	dict2 := Dictionary new.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	dict2 at: #a put: 3 ; at: #c put: 4.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
	dict1 addAll: dict2.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
	self assert: (dict1 at: #a) = 3.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
	self assert: (dict1 at: #b) = 2.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
	self assert: (dict1 at: #c) = 4.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
testAssociationsSelect
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
1547
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    31
        "(self selector: #testAssociationsSelect) run"
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
1547
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    33
        | answer d|
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
1547
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    35
        d := Dictionary new.
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    36
        d at: (Array with: #hello with: #world) put: #fooBar.
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    37
        d at: Smalltalk put: #'Smalltalk is the key'.
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    38
        d at: #Smalltalk put: Smalltalk.
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
1547
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    40
        answer := d associationsSelect:
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    41
                [:assoc | (assoc key == #Smalltalk) and: [assoc value == Smalltalk]].
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    42
        self should: [answer isKindOf: Dictionary].
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    43
        self should: [answer size == 1].
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    44
        self should: [(answer at: #Smalltalk) == Smalltalk].
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
1547
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    46
        answer := d associationsSelect:
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    47
                [:assoc | (assoc key == #NoSuchKey) and: [assoc value == #NoSuchValue]].
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    48
        self should: [answer isKindOf: Dictionary].
606e915e2216 #BUGFIX by sr
sr
parents: 1447
diff changeset
    49
        self should: [answer size == 0]
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
testComma
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
	"(self run: #testComma)"
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
    54
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
	| dict1 dict2 dict3 |
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
	dict1 := Dictionary new.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
    57
	dict1 at: #a put:1 ; at: #b put: 2.
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
	dict2 := Dictionary new.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
	dict2 at: #a put: 3 ; at: #c put: 4.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
	dict3 := dict1, dict2.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
	self assert: (dict3 at: #a) = 3.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
	self assert: (dict3 at: #b) = 2.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
	self assert: (dict3 at: #c) = 4.
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
!
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
testIncludesAssociation
1553
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    67
        "self debug: #testIncludesAssociation"
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
1553
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    69
        | d |
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    70
        d := Dictionary new
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    71
                at: #five put: 5;
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    72
                at: #givemefive put: 5;
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    73
                at: #six put: 6;
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    74
                yourself.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1055
diff changeset
    75
1553
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    76
        self assert: (d includesAssociation: (d associationAt: #five)).
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    77
        self assert: (d associationAt: #five) key == #five.
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    78
        self assert: (d associationAt: #five) value == 5.
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    79
        self assert: (d includesAssociation: (#five -> 5)).
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    80
        self assert: (d includesAssociation: (#five -> 6)) not.
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    81
5eecd405c903 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1547
diff changeset
    82
    "Modified: / 06-12-2016 / 14:19:15 / cg"
296
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
! !
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
!DictionaryTest class methodsFor:'documentation'!
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
version
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    ^ '$Header$'
ddacf68f6660 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
! !
1055
0d0b2641d00b category
Claus Gittinger <cg@exept.de>
parents: 296
diff changeset
    90