summaryrefslogtreecommitdiff
path: root/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala
blob: 8596613585ca28615f562ebe4fbed24236bd3721 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.rockymadden.stringmetric.cli.similarity

object ngrammetricSpec extends org.specs2.mutable.SpecificationWithJUnit {
	"ngrammetric main()" should {
		"print if they are a match with valid dashless arguments and valid n argument" in {
			val out = new java.io.ByteArrayOutputStream()

			Console.withOut(out)(ngrammetric.main(Array("--unitTest", "--debug", "--n=1", "abc", "abc")))
			out.toString must beEqualTo("1.0\n")
			out.reset()

			Console.withOut(out)(ngrammetric.main(Array("--unitTest", "--debug", "--n=1", "abc", "xyz")))
			out.toString must beEqualTo("0.0\n")
		}
		"throw IllegalArgumentException with valid dashless arguments but invalid n argument" in {
			ngrammetric.main(Array("--unitTest", "abc", "abc")) must throwA[IllegalArgumentException]
		}
		"throw IllegalArgumentException with no dashless arguments" in {
			ngrammetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException]
		}
	}
}