"{ Package: 'stx:goodies/regression' }"
"{ NameSpace: RegressionTests }"
TestCase subclass:#MetaphoneStringComparatorTest
instanceVariableNames:'sc'
classVariableNames:''
poolDictionaries:''
category:'tests-Regression-Collections-Utilities'
!
!MetaphoneStringComparatorTest methodsFor:'initialize / release'!
setUp
sc := PhoneticStringUtilities::MetaphoneStringComparator new
"Modified: / 02-08-2017 / 13:03:33 / cg"
! !
!MetaphoneStringComparatorTest methodsFor:'tests'!
test01_SomeCombinations
"tests if all char combinations up to size 4 can be soundexed"
|code s|
^ self.
self skip:'this test does not really test anything (except if all 4-char string combinations can be soundexed)'.
$A to:$Z do:[:c1 |
s := String with:c1.
code := (sc phoneticStringsFor:s) first.
$A to:$Z do:[:c2 |
s := String with:c1 with:c2.
code := (sc phoneticStringsFor:s) first.
$A to:$Z do:[:c3 |
s := String with:c1 with:c2 with:c3.
code := (sc phoneticStringsFor:s) first.
$A to:$Z do:[:c4 |
s := String with:c1 with:c2 with:c3 with:c4.
code := (sc phoneticStringsFor:s) first.
self assert:( code = s asSoundexCode).
].
].
].
].
"Created: / 27-07-2017 / 15:14:53 / cg"
"Modified: / 31-07-2017 / 17:51:21 / cg"
!
test02_WellKnownResults
"tests some wellknown metaphone codes"
#(
'a' 'A'
'Miller' 'MLR'
'ch' 'X'
'ANASTHA' 'ANS0'
'DAVIS-CARTER' 'TFSKRTR'
'ESCARMANT' 'ESKRMNT'
'MERSEAL' 'MRSL'
'PIEURISSAINT' 'PRSNT'
'ROTMAN' 'RTMN'
'SEAL' 'SL'
'SPARR' 'SPR'
'STARLEPER' 'STRLPR'
'THRASH' '0RX'
'LOGGING' 'LKNK'
'LOGIC' 'LJK'
'JUDGES' 'JJS'
'SHOOS' 'XS'
'SHOES' 'XS'
'OTTO' 'OT'
'ERIC' 'ERK'
'DAVE' 'TF'
'CATHERINE' 'K0RN'
'KATHERINE' 'K0RN'
'AUBREY' 'ABR'
'BRYAN' 'BRYN'
'BRYCE' 'BRS'
'STEVEN' 'STFN'
'HEIDI' 'HT'
'AUTO' 'AT'
'MAURICE' 'MRS'
'RANDY' 'RNT'
'CAMBRILLO' 'KMBRL'
'BRIAN' 'BRN'
'RAY' 'R'
'GEOFF' 'JF'
'BOB' 'BB'
'AHA' 'AH'
'AAH' 'A'
'PAUL' 'PL'
'BATTLEY' 'BTL'
'WROTE' 'RT'
'THIS' '0S'
'MCCALL' 'MKL'
'MCCROREY' 'MKRR'
'Sch' 'SX'
'Schi' 'SX'
'Schmid' 'SXMT'
'Schmidt' 'SXMTT' "/ bad, but that is how metaphone works
'Schmit' 'SXMT'
'Schmitt' 'SXMDT'
'CHUTE' 'XT'
'SCHEVEL' 'SXFL'
'SCHROM' 'SXRM'
'SCHUSS' 'SXS'
'RICHARD' 'RXRT'
) pairWiseDo:[:word :expected |
|whatIGot|
whatIGot := sc encode:word.
self assert: (whatIGot = expected).
].
"Created: / 27-07-2017 / 15:14:59 / cg"
"Modified (comment): / 03-08-2017 / 14:57:10 / cg"
!
test03_SomeCombinations
|code|
"/ code := (sc phoneticStringsFor:'AAH') first.
code := (sc encode:'AAH').
self assert:( code = 'A').
"Created: / 03-08-2017 / 14:53:40 / cg"
! !
!MetaphoneStringComparatorTest class methodsFor:'documentation'!
version
^ '$Header$'
!
version_CVS
^ '$Header$'
! !