blob: 9a029d8f6b287dda5f897db0549ab6a4440b513d (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
|
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 {
import MetaphoneMetricSpec.Metric
"MetaphoneMetric" should provide {
"compare method" when passed {
"empty arguments" should returns {
"None" in {
Metric.compare("", "").isDefined should be (false)
Metric.compare("abc", "").isDefined should be (false)
Metric.compare("", "xyz").isDefined should be (false)
}
}
"non-phonetic arguments" should returns {
"None" in {
Metric.compare("123", "123").isDefined should be (false)
Metric.compare("123", "").isDefined should be (false)
Metric.compare("", "123").isDefined should be (false)
}
}
"phonetically similar arguments" should returns {
"Boolean indicating true" in {
Metric.compare("dumb", "dum").get should be (true)
Metric.compare("smith", "smeth").get should be (true)
Metric.compare("merci", "mercy").get should be (true)
}
}
"phonetically dissimilar arguments" should returns {
"Boolean indicating false" in {
Metric.compare("dumb", "gum").get should be (false)
Metric.compare("smith", "kiss").get should be (false)
Metric.compare("merci", "burpy").get should be (false)
}
}
}
}
"MetaphoneMetric companion object" should provide {
"pass-through compare method" should returns {
"same value as class" in {
MetaphoneMetric.compare("dumb", "gum").get should be (false)
}
}
}
}
object MetaphoneMetricSpec {
final private val Metric = MetaphoneMetric()
}
|