summaryrefslogtreecommitdiff
path: root/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala
blob: 82cf8c28daf75f12580c2b90ad3ed2a2538dd962 (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
package com.rockymadden.stringmetric.cli.similarity

import com.rockymadden.stringmetric.cli.ScalaTest
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
final class dicesorensenmetricSpec extends ScalaTest { "dicesorensenmetric" 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)(
					dicesorensenmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc"))
				)

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

				Console.withOut(out)(
					dicesorensenmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz"))
				)

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