RegressionTests__MetaphoneStringComparatorTest.st
author Claus Gittinger <cg@exept.de>
Wed, 02 Aug 2017 13:07:43 +0200
changeset 1670 281404c7afd4
child 1675 af8e61132c06
permissions -rw-r--r--
initial checkin

"{ Package: 'stx:goodies/regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#MetaphoneStringComparatorTest
	instanceVariableNames:'sc'
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression-Collections-Utilities'
!


!MetaphoneStringComparatorTest methodsFor:'running'!

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 regular soundex"

    #(
        'Miller'    'MLR'
        'Schmid'    'SXMT'
    ) pairWiseDo:[:word :expected |   
        |whatIGot|

        whatIGot := sc encode:word.
        self assert: (whatIGot = expected).
    ].

    "Created: / 27-07-2017 / 15:14:59 / cg"
    "Modified: / 02-08-2017 / 13:05:56 / cg"
! !

!MetaphoneStringComparatorTest class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !