summaryrefslogtreecommitdiff
path: root/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala
blob: 1b22943dc600da14da424e001446fade905ef72e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.rockymadden.stringmetric.cli.phonetic

object metaphonealgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit {
	"metaphonealgorithm main()" should {
		"print phonetic representation with valid dashless argument" in {
			val out = new java.io.ByteArrayOutputStream()

			Console.withOut(out)(metaphonealgorithm.main(Array("--unitTest", "--debug", "abc")))
			out.toString must beEqualTo("abk\n")
			out.reset()

			Console.withOut(out)(metaphonealgorithm.main(Array("--unitTest", "--debug", "1")))
			out.toString must beEqualTo("not computable\n")
		}
		"throw IllegalArgumentException with no dashless argument" in {
			metaphonealgorithm.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException]
		}
	}
}