diff options
Diffstat (limited to 'cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/nGramAlgorithmSpec.scala')
-rwxr-xr-x | cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/nGramAlgorithmSpec.scala | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/nGramAlgorithmSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/nGramAlgorithmSpec.scala new file mode 100755 index 0000000..b68d5bb --- /dev/null +++ b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/nGramAlgorithmSpec.scala @@ -0,0 +1,66 @@ +package com.rockymadden.stringmetric.cli.similarity + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class nGramAlgorithmSpec extends ScalaTest { + "nGramAlgorithm" should provide { + "main method" when passed { + "valid dashless argument and valid n argument" should executes { + "print N-Gram representation" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + nGramAlgorithm.main( + Array( + "--unitTest", + "--debug", + "--n=1", + "abc" + ) + ) + ) + + out.toString should equal ("a|b|c\n") + out.reset() + + Console.withOut(out)( + nGramAlgorithm.main( + Array( + "--unitTest", + "--debug", + "--n=2", + "abc" + ) + ) + ) + + out.toString should equal ("ab|bc\n") + out.reset() + } + } + "valid dashless argument and invalid n argument" should throws { + "IllegalArgumentException" in { + evaluating { + nGramAlgorithm.main( + Array( + "--unitTest", + "abc", + "abc" + ) + ) + } should produce [IllegalArgumentException] + } + } + "no dashless argument" should throws { + "IllegalArgumentException" in { + evaluating { + nGramAlgorithm.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +}
\ No newline at end of file |