summaryrefslogtreecommitdiff
path: root/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala
blob: 94ff5dbf38ceb509b38170cff6fc91b90f894189 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.rockymadden.stringmetric.phonetic

import com.rockymadden.stringmetric.ScalaTest
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
final class MetaphoneMetricSpec extends ScalaTest {
	"MetaphoneMetric" should provide {
		"compare method" when passed {
			"empty arguments" should returns {
				"None" in {
					MetaphoneMetric.compare("", "").isDefined should be (false)
					MetaphoneMetric.compare("abc", "").isDefined should be (false)
					MetaphoneMetric.compare("", "xyz").isDefined should be (false)
				}
			}
			"non-phonetic arguments" should returns {
				"None" in {
					MetaphoneMetric.compare("123", "123").isDefined should be (false)
					MetaphoneMetric.compare("123", "").isDefined should be (false)
					MetaphoneMetric.compare("", "123").isDefined should be (false)
				}
			}
			"phonetically similar arguments" should returns {
				"Boolean indicating true" in {
					MetaphoneMetric.compare("dumb", "dum").get should be (true)
					MetaphoneMetric.compare("smith", "smeth").get should be (true)
					MetaphoneMetric.compare("merci", "mercy").get should be (true)
				}
			}
			"phonetically dissimilar arguments" should returns {
				"Boolean indicating false" in {
					MetaphoneMetric.compare("dumb", "gum").get should be (false)
					MetaphoneMetric.compare("smith", "kiss").get should be (false)
					MetaphoneMetric.compare("merci", "burpy").get should be (false)
				}
			}
		}
	}
}