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