RegressionTests__MRAStringComparatorTest.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2178 11781ca120e8
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding

"{ 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$'
! !