diff options
Diffstat (limited to 'cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizerSpec.scala')
-rwxr-xr-x | cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizerSpec.scala | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizerSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizerSpec.scala new file mode 100755 index 0000000..5fea2e9 --- /dev/null +++ b/cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizerSpec.scala @@ -0,0 +1,66 @@ +package com.rockymadden.stringmetric.cli.tokenize + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class ngramtokenizerSpec extends ScalaTest { + "ngramtokenizer" 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)( + ngramtokenizer.main( + Array( + "--unitTest", + "--debug", + "--n=1", + "abc" + ) + ) + ) + + out.toString should equal ("a|b|c\n") + out.reset() + + Console.withOut(out)( + ngramtokenizer.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 { + ngramtokenizer.main( + Array( + "--unitTest", + "abc", + "abc" + ) + ) + } should produce [IllegalArgumentException] + } + } + "no dashless argument" should throws { + "IllegalArgumentException" in { + evaluating { + ngramtokenizer.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} |