blob: c69d86043eef86441e2bf77d3e4c213c770e2f71 (
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
|
package com.rockymadden.stringmetric.similarity
import com.rockymadden.stringmetric.ScalaTest
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
final class HammingMetricSpec extends ScalaTest {
import HammingMetricSpec.Metric
"HammingMetric" 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)
}
}
"equal arguments" should returns {
"0" in {
Metric.compare("abc", "abc").get should be (0)
Metric.compare("123", "123").get should be (0)
}
}
"unequal arguments" should returns {
"Int indicating distance" in {
Metric.compare("abc", "xyz").get should be (3)
Metric.compare("123", "456").get should be (3)
}
}
"valid arguments" should returns {
"Int indicating distance" in {
Metric.compare("toned", "roses").get should be (3)
Metric.compare("1011101", "1001001").get should be (2)
Metric.compare("2173896", "2233796").get should be (3)
}
}
}
}
"HammingMetric companion object" should provide {
"pass-through compare method" should returns {
"same value as class" in {
HammingMetric.compare("2173896", "2233796").get should be (3)
}
}
}
}
object HammingMetricSpec {
private final val Metric = HammingMetric()
}
|