summaryrefslogtreecommitdiff
path: root/core/src/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala
blob: aae4cbccf6f9c12294c0efb6399419dae23fc438 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.rockymadden.stringmetric.phonetic

object MetaphoneMetricSpec extends org.specs2.mutable.SpecificationWithJUnit {
	"MetaphoneMetric compare()" should {
		"return None with empty arguments" in {
			MetaphoneMetric.compare("", "").isDefined must beFalse
			MetaphoneMetric.compare("abc", "").isDefined must beFalse
			MetaphoneMetric.compare("", "xyz").isDefined must beFalse
		}
		"return None with non-phonetic arguments" in {
			"None" in {
			MetaphoneMetric.compare("123", "123").isDefined must beFalse
			MetaphoneMetric.compare("123", "").isDefined must beFalse
			MetaphoneMetric.compare("", "123").isDefined must beFalse
			}
		}
		"return true with phonetically similar arguments" in {
			MetaphoneMetric.compare("dumb", "dum").get must beTrue
			MetaphoneMetric.compare("smith", "smeth").get must beTrue
			MetaphoneMetric.compare("merci", "mercy").get must beTrue
		}
		"return false with phonetically dissimilar arguments" in {
			MetaphoneMetric.compare("dumb", "gum").get must beFalse
			MetaphoneMetric.compare("smith", "kiss").get must beFalse
			MetaphoneMetric.compare("merci", "burpy").get must beFalse
		}
	}
}