summaryrefslogtreecommitdiff
path: root/core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala
blob: 7ce0c244ea9a3c766ba59147597f78f055b3abce (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
55
56
57
58
59
package com.rockymadden.stringmetric

import com.rockymadden.stringmetric.phonetic._
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
final class StringAlgorithmSpec extends ScalaTest {
	"StringAlgorithm standalone object" should provide {
		"compute method, type, and companion object pass-throughs" in {
			val metaphone: StringAlgorithm.Metaphone = StringAlgorithm.Metaphone()

			metaphone.compute("testone").get should
				equal (StringAlgorithm.computeWithMetaphone("testone").get)
			metaphone.compute("testone".toCharArray).get should
				equal (StringAlgorithm.computeWithMetaphone("testone".toCharArray).get)
			metaphone.compute("testone".toCharArray).get should
				equal (MetaphoneAlgorithm.compute("testone".toCharArray).get)

			val nysiis: StringAlgorithm.Nysiis = StringAlgorithm.Nysiis()

			nysiis.compute("testone").get should
				equal (StringAlgorithm.computeWithNysiis("testone").get)
			nysiis.compute("testone".toCharArray).get should
				equal (StringAlgorithm.computeWithNysiis("testone".toCharArray).get)
			nysiis.compute("testone".toCharArray).get should
				equal (NysiisAlgorithm.compute("testone".toCharArray).get)

			val refinedNysiis: StringAlgorithm.RefinedNysiis = StringAlgorithm.RefinedNysiis()

			refinedNysiis.compute("testone").get should
				equal (StringAlgorithm.computeWithRefinedNysiis("testone").get)
			refinedNysiis.compute("testone".toCharArray).get should
				equal (StringAlgorithm.computeWithRefinedNysiis("testone".toCharArray).get)
			refinedNysiis.compute("testone".toCharArray).get should
				equal (RefinedNysiisAlgorithm.compute("testone".toCharArray).get)

			val refinedSoundex: StringAlgorithm.RefinedSoundex = StringAlgorithm.RefinedSoundex()

			refinedSoundex.compute("testone").get should
				equal (StringAlgorithm.computeWithRefinedSoundex("testone").get)
			refinedSoundex.compute("testone".toCharArray).get should
				equal (StringAlgorithm.computeWithRefinedSoundex("testone".toCharArray).get)
			refinedSoundex.compute("testone".toCharArray).get should
				equal (RefinedSoundexAlgorithm.compute("testone".toCharArray).get)

			val soundex: StringAlgorithm.Soundex = StringAlgorithm.Soundex()

			soundex.compute("testone").get should
				equal (StringAlgorithm.computeWithSoundex("testone").get)
			soundex.compute("testone".toCharArray).get should
				equal (StringAlgorithm.computeWithSoundex("testone".toCharArray).get)
			soundex.compute("testone".toCharArray).get should
				equal (SoundexAlgorithm.compute("testone".toCharArray).get)
		}
	}
}