1667
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#Metaphone3StringComparatorTest
|
|
6 |
instanceVariableNames:'sc'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'tests-Regression-Collections-Utilities'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
2177
|
13 |
!Metaphone3StringComparatorTest methodsFor:'initialize / release'!
|
1667
|
14 |
|
|
15 |
setUp
|
|
16 |
Metaphone3StringComparator notNil ifTrue:[
|
|
17 |
sc := Metaphone3StringComparator new.
|
|
18 |
^ self.
|
|
19 |
].
|
|
20 |
PhoneticStringUtilities::Metaphone3StringComparator notNil ifTrue:[
|
|
21 |
sc := PhoneticStringUtilities::Metaphone3StringComparator new.
|
|
22 |
^ self.
|
|
23 |
].
|
|
24 |
sc := nil
|
|
25 |
|
|
26 |
"Modified: / 31-07-2017 / 20:01:35 / cg"
|
|
27 |
! !
|
|
28 |
|
|
29 |
!Metaphone3StringComparatorTest methodsFor:'tests'!
|
|
30 |
|
|
31 |
test01_SomeCombinations
|
|
32 |
"tests if all character combinations (up to 4 chars) are handled"
|
|
33 |
|
|
34 |
|code s|
|
|
35 |
|
|
36 |
self skipIf:sc isNil description:'no Metaphone3 class'.
|
|
37 |
|
|
38 |
$A to:$Z do:[:c1 |
|
|
39 |
s := String with:c1.
|
|
40 |
code := (sc phoneticStringsFor:s) first.
|
|
41 |
self assert:( code notEmpty).
|
|
42 |
self assert:( code conform:#isLetterOrDigit).
|
|
43 |
|
|
44 |
$A to:$Z do:[:c2 |
|
|
45 |
s := String with:c1 with:c2.
|
|
46 |
code := (sc phoneticStringsFor:s) first.
|
|
47 |
self assert:( code notEmpty).
|
|
48 |
self assert:( code conform:#isLetterOrDigit).
|
|
49 |
|
|
50 |
$A to:$Z do:[:c3 |
|
|
51 |
s := String with:c1 with:c2 with:c3.
|
|
52 |
code := (sc phoneticStringsFor:s) first.
|
|
53 |
self assert:( code notEmpty).
|
|
54 |
self assert:( code conform:#isLetterOrDigit).
|
|
55 |
|
|
56 |
$A to:$Z do:[:c4 |
|
|
57 |
s := String with:c1 with:c2 with:c3 with:c4.
|
|
58 |
code := (sc phoneticStringsFor:s) first.
|
|
59 |
self assert:( code notEmpty).
|
|
60 |
self assert:( code conform:#isLetterOrDigit).
|
|
61 |
].
|
|
62 |
].
|
|
63 |
].
|
|
64 |
].
|
|
65 |
|
|
66 |
"Created: / 27-07-2017 / 15:14:53 / cg"
|
|
67 |
"Modified: / 31-07-2017 / 23:10:17 / cg"
|
|
68 |
!
|
|
69 |
|
|
70 |
test02_WellKnownResults
|
|
71 |
"tests regular soundex"
|
|
72 |
|
|
73 |
|code soundex|
|
|
74 |
|
|
75 |
self skipIf:sc isNil description:'no Metaphone3 class'.
|
|
76 |
|
|
77 |
soundex := [:w | (sc phoneticStringsFor:w) first].
|
|
78 |
|
|
79 |
self assert: ( code := soundex value:( 'banknote' )) = 'PNKNT' .
|
|
80 |
self assert: ( code := soundex value:( 'slipknot' )) = 'SLPNT' .
|
|
81 |
self assert: ( code := soundex value:( 'miller' )) = 'MLR' .
|
|
82 |
self assert: ( code := soundex value:( 'gittinger' )) = 'KTNJR' .
|
|
83 |
self assert: ( code := soundex value:( 'henry' )) = 'NR' .
|
|
84 |
|
|
85 |
self assert: ( code := soundex value:( 'penknife' )) = 'PNF' .
|
|
86 |
self assert: ( code := soundex value:( 'pennife' )) = 'PNF' .
|
|
87 |
|
|
88 |
self assert: ( code := soundex value:( 'goethe' )) = 'KT' .
|
|
89 |
self assert: ( code := soundex value:( 'gothere' )) = 'K0R' .
|
|
90 |
self assert: ( code := soundex value:( 'goth' )) = 'K0' .
|
|
91 |
self assert: ( code := soundex value:( 'gothic' )) = 'K0K' .
|
|
92 |
|
2177
|
93 |
self assert: ( code := soundex value:( 'MONSIEUR' )) = 'MS'. "/ mosiö
|
1667
|
94 |
|
|
95 |
"Created: / 27-07-2017 / 15:14:59 / cg"
|
|
96 |
"Modified: / 31-07-2017 / 20:01:26 / cg"
|
|
97 |
! !
|
|
98 |
|
|
99 |
!Metaphone3StringComparatorTest class methodsFor:'documentation'!
|
|
100 |
|
|
101 |
version
|
|
102 |
^ '$Header$'
|
|
103 |
!
|
|
104 |
|
|
105 |
version_CVS
|
|
106 |
^ '$Header$'
|
|
107 |
! !
|
|
108 |
|