"{ Package: 'stx:goodies/regression' }"
"{ NameSpace: RegressionTests }"
TestCase subclass:#Metaphone3StringComparatorTest
instanceVariableNames:'sc'
classVariableNames:''
poolDictionaries:''
category:'tests-Regression-Collections-Utilities'
!
!Metaphone3StringComparatorTest methodsFor:'initialize / release'!
setUp
Metaphone3StringComparator notNil ifTrue:[
sc := Metaphone3StringComparator new.
^ self.
].
PhoneticStringUtilities::Metaphone3StringComparator notNil ifTrue:[
sc := PhoneticStringUtilities::Metaphone3StringComparator new.
^ self.
].
sc := nil
"Modified: / 31-07-2017 / 20:01:35 / cg"
! !
!Metaphone3StringComparatorTest methodsFor:'tests'!
test01_SomeCombinations
"tests if all character combinations (up to 4 chars) are handled"
|code s|
self skipIf:sc isNil description:'no Metaphone3 class'.
$A to:$Z do:[:c1 |
s := String with:c1.
code := (sc phoneticStringsFor:s) first.
self assert:( code notEmpty).
self assert:( code conform:#isLetterOrDigit).
$A to:$Z do:[:c2 |
s := String with:c1 with:c2.
code := (sc phoneticStringsFor:s) first.
self assert:( code notEmpty).
self assert:( code conform:#isLetterOrDigit).
$A to:$Z do:[:c3 |
s := String with:c1 with:c2 with:c3.
code := (sc phoneticStringsFor:s) first.
self assert:( code notEmpty).
self assert:( code conform:#isLetterOrDigit).
$A to:$Z do:[:c4 |
s := String with:c1 with:c2 with:c3 with:c4.
code := (sc phoneticStringsFor:s) first.
self assert:( code notEmpty).
self assert:( code conform:#isLetterOrDigit).
].
].
].
].
"Created: / 27-07-2017 / 15:14:53 / cg"
"Modified: / 31-07-2017 / 23:10:17 / cg"
!
test02_WellKnownResults
"tests regular soundex"
|code soundex|
self skipIf:sc isNil description:'no Metaphone3 class'.
soundex := [:w | (sc phoneticStringsFor:w) first].
self assert: ( code := soundex value:( 'banknote' )) = 'PNKNT' .
self assert: ( code := soundex value:( 'slipknot' )) = 'SLPNT' .
self assert: ( code := soundex value:( 'miller' )) = 'MLR' .
self assert: ( code := soundex value:( 'gittinger' )) = 'KTNJR' .
self assert: ( code := soundex value:( 'henry' )) = 'NR' .
self assert: ( code := soundex value:( 'penknife' )) = 'PNF' .
self assert: ( code := soundex value:( 'pennife' )) = 'PNF' .
self assert: ( code := soundex value:( 'goethe' )) = 'KT' .
self assert: ( code := soundex value:( 'gothere' )) = 'K0R' .
self assert: ( code := soundex value:( 'goth' )) = 'K0' .
self assert: ( code := soundex value:( 'gothic' )) = 'K0K' .
self assert: ( code := soundex value:( 'MONSIEUR' )) = 'MS'. "/ mosiö
"Created: / 27-07-2017 / 15:14:59 / cg"
"Modified: / 31-07-2017 / 20:01:26 / cg"
! !
!Metaphone3StringComparatorTest class methodsFor:'documentation'!
version
^ '$Header$'
!
version_CVS
^ '$Header$'
! !