initial checkin
authorClaus Gittinger <cg@exept.de>
Tue, 01 Aug 2017 11:45:14 +0200
changeset 1667 53e3bb6acc3f
parent 1666 b2721079846a
child 1668 c9120dbc953f
initial checkin
RegressionTests__Metaphone3StringComparatorTest.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RegressionTests__Metaphone3StringComparatorTest.st	Tue Aug 01 11:45:14 2017 +0200
@@ -0,0 +1,110 @@
+"{ Encoding: utf8 }"
+
+"{ Package: 'stx:goodies/regression' }"
+
+"{ NameSpace: RegressionTests }"
+
+TestCase subclass:#Metaphone3StringComparatorTest
+	instanceVariableNames:'sc'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'tests-Regression-Collections-Utilities'
+!
+
+
+!Metaphone3StringComparatorTest methodsFor:'running'!
+
+setUp
+    Metaphone3StringComparator notNil ifTrue:[
+        sc := Metaphone3StringComparator new.
+        ^ self.
+    ].    
+    PhoneticStringUtilities::Metaphone3StringComparator notNil ifTrue:[
+        sc := PhoneticStringUtilities::Metaphone3StringComparator new.
+        ^ self.
+    ].    
+    sc := nil
+
+    "Modified: / 31-07-2017 / 20:01:35 / cg"
+! !
+
+!Metaphone3StringComparatorTest methodsFor:'tests'!
+
+test01_SomeCombinations
+    "tests if all character combinations (up to 4 chars) are handled"
+    
+    |code s|
+
+    self skipIf:sc isNil description:'no Metaphone3 class'.
+    
+    $A to:$Z do:[:c1 |
+        s := String with:c1.
+        code := (sc phoneticStringsFor:s) first.
+        self assert:( code notEmpty).
+        self assert:( code conform:#isLetterOrDigit).
+
+        $A to:$Z do:[:c2 |
+            s := String with:c1 with:c2.
+            code := (sc phoneticStringsFor:s) first.
+            self assert:( code notEmpty).
+            self assert:( code conform:#isLetterOrDigit).
+
+            $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:#isLetterOrDigit).
+
+                $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:#isLetterOrDigit).
+                ].
+            ].
+        ].
+    ].
+
+    "Created: / 27-07-2017 / 15:14:53 / cg"
+    "Modified: / 31-07-2017 / 23:10:17 / cg"
+!
+
+test02_WellKnownResults
+    "tests regular soundex"
+
+    |code soundex|
+
+    self skipIf:sc isNil description:'no Metaphone3 class'.
+
+    soundex := [:w | (sc phoneticStringsFor:w) first].
+
+    self assert: ( code := soundex value:( 'banknote' )) = 'PNKNT' .
+    self assert: ( code := soundex value:( 'slipknot' )) = 'SLPNT' .
+    self assert: ( code := soundex value:( 'miller' )) = 'MLR' .
+    self assert: ( code := soundex value:( 'gittinger' )) = 'KTNJR' .
+    self assert: ( code := soundex value:( 'henry' )) = 'NR' .
+
+    self assert: ( code := soundex value:( 'penknife' )) = 'PNF' .
+    self assert: ( code := soundex value:( 'pennife' )) = 'PNF' .
+
+    self assert: ( code := soundex value:( 'goethe' )) = 'KT' .
+    self assert: ( code := soundex value:( 'gothere' )) = 'K0R' .
+    self assert: ( code := soundex value:( 'goth' )) = 'K0' .
+    self assert: ( code := soundex value:( 'gothic' )) = 'K0K' .
+
+    self assert: ( code := soundex value:( 'MONSIEUR' )) = 'MS'.  "/ mosiƶ
+
+    "Created: / 27-07-2017 / 15:14:59 / cg"
+    "Modified: / 31-07-2017 / 20:01:26 / cg"
+! !
+
+!Metaphone3StringComparatorTest class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+!
+
+version_CVS
+    ^ '$Header$'
+! !
+