RegressionTests__MRAStringComparatorTest.st
author Stefan Vogel <sv@exept.de>
Tue, 11 Jun 2019 10:34:41 +0200
changeset 2321 32ea6329f5ad
parent 2178 11781ca120e8
permissions -rw-r--r--
class: stx_goodies_regression class changed: #classNamesAndAttributes make classes autoloaded that stc cannot compile (yet)

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

"{ NameSpace: RegressionTests }"

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


!MRAStringComparatorTest methodsFor:'initialize / release'!

setUp
    sc := PhoneticStringUtilities::MRAStringComparator new

    "Modified: / 31-07-2017 / 15:16:50 / cg"
! !

!MRAStringComparatorTest methodsFor:'tests'!

test01_SomeCombinations
    "tests if all character combinations (up to 4 chars) are handled"
    
    |code s|

    $A to:$Z do:[:c1 |
        s := String with:c1.
        code := (sc phoneticStringsFor:s) first.
        self assert:( code notEmpty).
        self assert:( code conform:#isLetter).
        self assert:( code size == 1).
        self assert:( code first == c1).

        $A to:$Z do:[:c2 |
            s := String with:c1 with:c2.
            code := (sc phoneticStringsFor:s) first.
            self assert:( code notEmpty).
            self assert:( code conform:#isLetter).
            self assert:( code first == c1).

            $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:#isLetter).
                self assert:( code first == c1).

                $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:#isLetter).
                    self assert:( code first == c1).
                ].
            ].
        ].
    ].

    "Created: / 27-07-2017 / 15:14:53 / cg"
    "Modified: / 31-07-2017 / 15:19:29 / cg"
!

test02_WellKnownResults
    "tests regular soundex"

    |code soundex|

    soundex := [:w | (sc phoneticStringsFor:w) first].

    self assert: ( code := soundex value:( 'Catherine' ))          = 'CTHRN' .
    self assert: ( code := soundex value:( 'CatherineCatherine' )) = 'CTHHRN' .
    self assert: ( code := soundex value:( 'Butter' )) = 'BTR' .
    self assert: ( code := soundex value:( 'Byrne' )) = 'BYRN' .
    self assert: ( code := soundex value:( 'Boern' )) = 'BRN' .
    self assert: ( code := soundex value:( 'Smith' )) = 'SMTH' .
    self assert: ( code := soundex value:( 'Smyth' )) = 'SMYTH' .
    self assert: ( code := soundex value:( 'Kathryn' )) = 'KTHRYN' .

    "Created: / 27-07-2017 / 15:14:59 / cg"
    "Modified: / 31-07-2017 / 15:16:35 / cg"
! !

!MRAStringComparatorTest class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !