RegressionTests__MRAStringComparatorTest.st
changeset 1669 c19be5635e84
child 2178 11781ca120e8
equal deleted inserted replaced
1668:c9120dbc953f 1669:c19be5635e84
       
     1 "{ Package: 'stx:goodies/regression' }"
       
     2 
       
     3 "{ NameSpace: RegressionTests }"
       
     4 
       
     5 TestCase subclass:#MRAStringComparatorTest
       
     6 	instanceVariableNames:'sc'
       
     7 	classVariableNames:''
       
     8 	poolDictionaries:''
       
     9 	category:'tests-Regression-Collections-Utilities'
       
    10 !
       
    11 
       
    12 
       
    13 !MRAStringComparatorTest methodsFor:'running'!
       
    14 
       
    15 setUp
       
    16     sc := PhoneticStringUtilities::MRAStringComparator new
       
    17 
       
    18     "Modified: / 31-07-2017 / 15:16:50 / cg"
       
    19 ! !
       
    20 
       
    21 !MRAStringComparatorTest methodsFor:'tests'!
       
    22 
       
    23 test01_SomeCombinations
       
    24     "tests if all character combinations (up to 4 chars) are handled"
       
    25     
       
    26     |code s|
       
    27 
       
    28     $A to:$Z do:[:c1 |
       
    29         s := String with:c1.
       
    30         code := (sc phoneticStringsFor:s) first.
       
    31         self assert:( code notEmpty).
       
    32         self assert:( code conform:#isLetter).
       
    33         self assert:( code size == 1).
       
    34         self assert:( code first == c1).
       
    35 
       
    36         $A to:$Z do:[:c2 |
       
    37             s := String with:c1 with:c2.
       
    38             code := (sc phoneticStringsFor:s) first.
       
    39             self assert:( code notEmpty).
       
    40             self assert:( code conform:#isLetter).
       
    41             self assert:( code first == c1).
       
    42 
       
    43             $A to:$Z do:[:c3 |
       
    44                 s := String with:c1 with:c2 with:c3.
       
    45                 code := (sc phoneticStringsFor:s) first.
       
    46                 self assert:( code notEmpty).
       
    47                 self assert:( code conform:#isLetter).
       
    48                 self assert:( code first == c1).
       
    49 
       
    50                 $A to:$Z do:[:c4 |
       
    51                     s := String with:c1 with:c2 with:c3 with:c4.
       
    52                     code := (sc phoneticStringsFor:s) first.
       
    53                     self assert:( code notEmpty).
       
    54                     self assert:( code conform:#isLetter).
       
    55                     self assert:( code first == c1).
       
    56                 ].
       
    57             ].
       
    58         ].
       
    59     ].
       
    60 
       
    61     "Created: / 27-07-2017 / 15:14:53 / cg"
       
    62     "Modified: / 31-07-2017 / 15:19:29 / cg"
       
    63 !
       
    64 
       
    65 test02_WellKnownResults
       
    66     "tests regular soundex"
       
    67 
       
    68     |code soundex|
       
    69 
       
    70     soundex := [:w | (sc phoneticStringsFor:w) first].
       
    71 
       
    72     self assert: ( code := soundex value:( 'Catherine' ))          = 'CTHRN' .
       
    73     self assert: ( code := soundex value:( 'CatherineCatherine' )) = 'CTHHRN' .
       
    74     self assert: ( code := soundex value:( 'Butter' )) = 'BTR' .
       
    75     self assert: ( code := soundex value:( 'Byrne' )) = 'BYRN' .
       
    76     self assert: ( code := soundex value:( 'Boern' )) = 'BRN' .
       
    77     self assert: ( code := soundex value:( 'Smith' )) = 'SMTH' .
       
    78     self assert: ( code := soundex value:( 'Smyth' )) = 'SMYTH' .
       
    79     self assert: ( code := soundex value:( 'Kathryn' )) = 'KTHRYN' .
       
    80 
       
    81     "Created: / 27-07-2017 / 15:14:59 / cg"
       
    82     "Modified: / 31-07-2017 / 15:16:35 / cg"
       
    83 ! !
       
    84 
       
    85 !MRAStringComparatorTest class methodsFor:'documentation'!
       
    86 
       
    87 version
       
    88     ^ '$Header$'
       
    89 !
       
    90 
       
    91 version_CVS
       
    92     ^ '$Header$'
       
    93 ! !
       
    94