1447
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
1124
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#TSTreeTests
|
|
6 |
instanceVariableNames:'tree empty'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'tests-Regression-Collections'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!TSTreeTests methodsFor:'as yet unclassified'!
|
|
14 |
|
|
15 |
testAt
|
|
16 |
self assert: (tree at: 'abear') = 'ABEAR'.
|
|
17 |
self assert: (tree at: 'abelmosk') = 'ABELMOSK'.
|
|
18 |
self assert: (tree at: 'abracadabra' ifAbsent: [42]) = 42.
|
|
19 |
self assert: (tree at: '' ifAbsent: [42]) = 42.
|
1447
|
20 |
self assert: (empty at: 'foo' ifAbsent: [42]) = 42
|
1124
|
21 |
!
|
|
22 |
|
|
23 |
testMatch
|
|
24 |
self assert: (tree matchesForString: 'abea' distance: 1) asSet = #(ABEAM ABEAR ABED ABEL ABET ABE) asSet.
|
|
25 |
self assert: (tree matchesForString: 'abel' distance: 2) asSet = #(ABELIA ABEAM ABEAR) asSet.
|
|
26 |
self assert: (tree matchesForString: 'abel' distance: 0) = #(ABEL).
|
|
27 |
self assert: (tree matchesForString: '' distance: 1) = #().
|
|
28 |
self assert: (empty matchesForString: 'foo' distance: 0) = #()
|
|
29 |
!
|
|
30 |
|
|
31 |
testPrefix
|
|
32 |
self assert: (tree matchesForPrefix: 'abet') asSet = #(ABET ABETMENT) asSet.
|
|
33 |
self assert: (tree matchesForPrefix: 'abelm') asSet = #(ABELMOSCHUS ABELMOSK) asSet.
|
|
34 |
self assert: (tree matchesForPrefix: '') asSet = (self words asSet collect: [:ea | ea asUppercase]).
|
|
35 |
self assert: (empty matchesForPrefix: 'foo') = #()
|
|
36 |
!
|
|
37 |
|
|
38 |
testRemove
|
|
39 |
self assert: (tree at: 'abel') = 'ABEL'.
|
|
40 |
self assert: (tree removeKey: 'abel') = 'ABEL'.
|
|
41 |
self assert: (tree at: 'abel' ifAbsent: [42]) = 42.
|
|
42 |
self assert: (tree at: 'abelmosk') = 'ABELMOSK'.
|
|
43 |
self assert: (tree removeKey: 'foo' ifAbsent: [42]) = 42.
|
|
44 |
self assert: (tree removeKey: 'abel' ifAbsent: [42]) = 42.
|
|
45 |
!
|
|
46 |
|
|
47 |
testValues
|
|
48 |
self assert: tree values asSet = (self words asSet collect: [:ea | ea asUppercase]).
|
|
49 |
self assert: empty values isEmpty
|
|
50 |
!
|
|
51 |
|
|
52 |
tstreeClass
|
|
53 |
^ TSTree
|
|
54 |
!
|
|
55 |
|
|
56 |
words
|
|
57 |
^ #(
|
|
58 |
abe
|
|
59 |
abeam
|
|
60 |
abear
|
|
61 |
abearance
|
|
62 |
abecedarian
|
|
63 |
abecedarium
|
|
64 |
abecedary
|
|
65 |
abed
|
|
66 |
abeigh
|
|
67 |
abel
|
|
68 |
abele
|
|
69 |
abelia
|
|
70 |
abelian
|
|
71 |
abelicea
|
|
72 |
abelite
|
|
73 |
abelite
|
|
74 |
abelmoschus
|
|
75 |
abelmosk
|
|
76 |
abelonian
|
|
77 |
abeltree
|
|
78 |
abencerrages
|
|
79 |
abenteric
|
|
80 |
abepithymia
|
|
81 |
aberdeen
|
|
82 |
aberdevine
|
|
83 |
aberdonian
|
|
84 |
aberia
|
|
85 |
aberrance
|
|
86 |
aberrancy
|
|
87 |
aberrant
|
|
88 |
aberrate
|
|
89 |
aberration
|
|
90 |
aberrational
|
|
91 |
aberrator
|
|
92 |
aberrometer
|
|
93 |
aberroscope
|
|
94 |
aberuncator
|
|
95 |
abet
|
1447
|
96 |
abetment)
|
1124
|
97 |
! !
|
|
98 |
|
2186
|
99 |
!TSTreeTests methodsFor:'initialize / release'!
|
|
100 |
|
|
101 |
setUp
|
|
102 |
tree := self tstreeClass new.
|
|
103 |
self words shuffled do:[:ea |
|
|
104 |
tree at:ea put:ea asUppercase
|
|
105 |
].
|
|
106 |
empty := self tstreeClass new.
|
|
107 |
! !
|
|
108 |
|
1124
|
109 |
!TSTreeTests class methodsFor:'documentation'!
|
|
110 |
|
|
111 |
version
|
|
112 |
^ '$Header$'
|
|
113 |
!
|
|
114 |
|
|
115 |
version_CVS
|
|
116 |
^ '$Header$'
|
|
117 |
! !
|
|
118 |
|