summaryrefslogtreecommitdiff
path: root/cli/source/test/scala/org/hashtree/stringmetric/cli/phonetic/refinedNysiisMetricSpec.scala
blob: eddee0aece1b21755169a978f47c18ed0e8572e0 (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
package org.hashtree.stringmetric.cli.phonetic

import org.hashtree.stringmetric.ScalaTest
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
final class refinedNysiisMetricSpec extends ScalaTest {
	"refinedNysiisMetric" should provide {
		"main method" when passed {
			"valid dashless arguments" should executes {
				"print if they are a match" in {
					val out = new java.io.ByteArrayOutputStream()

					Console.withOut(out)(
						refinedNysiisMetric.main(Array("--unitTest", "--debug", "abc", "abc"))
					)

					out.toString should equal ("true\n")
					out.reset()

					Console.withOut(out)(
						refinedNysiisMetric.main(Array("--unitTest", "--debug", "abc", "xyz"))
					)

					out.toString should equal ("false\n")
					out.reset()

					Console.withOut(out)(
						refinedNysiisMetric.main(Array("--unitTest", "--debug", "1", "1"))
					)

					out.toString should equal ("not comparable\n")
					out.reset()
				}
			}
			"no dashless arguments" should throws {
				"IllegalArgumentException" in {
					evaluating {
						refinedNysiisMetric.main(Array("--unitTest", "--debug"))
					} should produce [IllegalArgumentException]
				}
			}
		}
	}
}