summaryrefslogtreecommitdiff
path: root/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala
blob: cb6a222041395c279aefd18a6060f2ad15543e93 (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
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 RefinedSoundexMetricSpec extends ScalaTest {
	import RefinedSoundexMetricSpec.Metric

	"RefinedSoundexMetric" 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("robert", "rupert").get should be (true)
				}
			}
			"phonetically dissimilar arguments" should returns {
				"Boolean indicating false" in {
					Metric.compare("robert", "rubin").get should be (false)
				}
			}
		}
	}
	"RefinedSoundexMetric companion object" should provide {
		"pass-through compare method" should returns {
			"same value as class" in {
				RefinedSoundexMetric.compare("robert", "rubin").get should be (false)
			}
		}
	}
}

object RefinedSoundexMetricSpec {
	final private val Metric = RefinedSoundexMetric()
}