diff options
Diffstat (limited to 'stringmetric-cli/source/test/scala/com/rockymadden')
22 files changed, 1078 insertions, 0 deletions
diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/OptionMapSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/OptionMapSpec.scala new file mode 100755 index 0000000..121e2ed --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/OptionMapSpec.scala @@ -0,0 +1,84 @@ +package com.rockymadden.stringmetric.cli + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class OptionMapSpec extends ScalaTest { + "OptionMap" should provide { + "apply method" when passed { + "single valid double dashed option" should returns { + "populated Map" in { + val opts: OptionMap = Array("--help") + + (opts('help): String) should equal ("") + } + } + "multiple valid double dashed opts" should returns { + "populated Map" in { + val opts: OptionMap = Array("--help", "--test=test") + + (opts('help): String) should equal ("") + (opts('test): String) should equal ("test") + } + } + "invalid double dashed opts" should returns { + "empty Map" in { + val opts: OptionMap = Array("--help#", "--test%=test") + + opts.keysIterator.length should be (0) + } + } + "single valid single dashed option" should returns { + "populated Map" in { + val opts: OptionMap = Array("-h") + + (opts('h): String) should equal ("") + } + } + "multiple valid single dashed opts" should returns { + "populated Map" in { + val opts: OptionMap = Array("-h", "-i") + + (opts('h): String) should equal ("") + (opts('i): String) should equal ("") + } + } + "invalid single dashed opts" should returns { + "empty Map" in { + val opts: OptionMap = Array("-h-i", "-i#gloo") + + opts.keysIterator.length should be (0) + } + } + "single nameless option" should returns { + "single key populated Map" in { + val opts: OptionMap = Array("filename0") + + (opts('dashless): String).count(_ == ' ') should be (0) + } + } + "multiple single nameless opts" should returns { + "single key populated Map" in { + val opts: OptionMap = Array("filename0", "filename1", "filename2") + + (opts('dashless): String).count(_ == ' ') should be (2) + } + } + "mixed opts" should returns { + "populated Map" in { + val opts: OptionMap = Array( + "-q", "--help", "--test=test", "-go", "filename0", "filename1", "filename2" + ) + + (opts('q): String) should equal ("") + (opts('help): String) should equal ("") + (opts('test): String) should equal ("test") + (opts('go): String) should equal ("") + (opts('dashless): String).count(_ == ' ') should be (2) + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala new file mode 100755 index 0000000..68bdcf7 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala @@ -0,0 +1,39 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class metaphonealgorithmSpec extends ScalaTest { + "metaphonealgorithm" should provide { + "main method" when passed { + "valid dashless argument" should executes { + "print phonetic representation" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + metaphonealgorithm.main(Array("--unitTest", "--debug", "abc")) + ) + + out.toString should equal ("abk\n") + out.reset() + + Console.withOut(out)( + metaphonealgorithm.main(Array("--unitTest", "--debug", "1")) + ) + + out.toString should equal ("not computable\n") + out.reset() + } + } + "no dashless argument" should throws { + "IllegalArgumentException" in { + evaluating { + metaphonealgorithm.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala new file mode 100755 index 0000000..4e6567e --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala @@ -0,0 +1,46 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class metaphonemetricSpec extends ScalaTest { + "metaphonemetric" 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)( + metaphonemetric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("true\n") + out.reset() + + Console.withOut(out)( + metaphonemetric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("false\n") + out.reset() + + Console.withOut(out)( + metaphonemetric.main(Array("--unitTest", "--debug", "1", "1")) + ) + + out.toString should equal ("not comparable\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + metaphonemetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala new file mode 100755 index 0000000..3683d2d --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala @@ -0,0 +1,39 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class nysiisalgorithmSpec extends ScalaTest { + "nysiisalgorithm" should provide { + "main method" when passed { + "valid dashless argument" should executes { + "print phonetic representation" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + nysiisalgorithm.main(Array("--unitTest", "--debug", "abc")) + ) + + out.toString should equal ("abc\n") + out.reset() + + Console.withOut(out)( + nysiisalgorithm.main(Array("--unitTest", "--debug", "1")) + ) + + out.toString should equal ("not computable\n") + out.reset() + } + } + "no dashless argument" should throws { + "IllegalArgumentException" in { + evaluating { + nysiisalgorithm.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala new file mode 100755 index 0000000..6898025 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala @@ -0,0 +1,46 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class nysiismetricSpec extends ScalaTest { + "nysiismetric" 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)( + nysiismetric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("true\n") + out.reset() + + Console.withOut(out)( + nysiismetric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("false\n") + out.reset() + + Console.withOut(out)( + nysiismetric.main(Array("--unitTest", "--debug", "1", "1")) + ) + + out.toString should equal ("not comparable\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + nysiismetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala new file mode 100755 index 0000000..f5376fa --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala @@ -0,0 +1,39 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class refinednysiisalgorithmSpec extends ScalaTest { + "refinednysiisalgorithm" should provide { + "main method" when passed { + "valid dashless argument" should executes { + "print phonetic representation" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + refinednysiisalgorithm.main(Array("--unitTest", "--debug", "abc")) + ) + + out.toString should equal ("abc\n") + out.reset() + + Console.withOut(out)( + refinednysiisalgorithm.main(Array("--unitTest", "--debug", "1")) + ) + + out.toString should equal ("not computable\n") + out.reset() + } + } + "no dashless argument" should throws { + "IllegalArgumentException" in { + evaluating { + refinednysiisalgorithm.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala new file mode 100755 index 0000000..4b4889d --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala @@ -0,0 +1,46 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class refinednysiismetricSpec extends ScalaTest { + "refinednysiismetric" 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)( + refinednysiismetric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("true\n") + out.reset() + + Console.withOut(out)( + refinednysiismetric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("false\n") + out.reset() + + Console.withOut(out)( + refinednysiismetric.main(Array("--unitTest", "--debug", "1", "1")) + ) + + out.toString should equal ("not comparable\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + refinednysiismetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala new file mode 100755 index 0000000..80a8fd2 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala @@ -0,0 +1,39 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class refinedsoundexalgorithmSpec extends ScalaTest { + "refinedsoundexalgorithm" should provide { + "main method" when passed { + "valid dashless argument" should executes { + "print phonetic representation" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + refinedsoundexalgorithm.main(Array("--unitTest", "--debug", "abc")) + ) + + out.toString should equal ("a013\n") + out.reset() + + Console.withOut(out)( + refinedsoundexalgorithm.main(Array("--unitTest", "--debug", "1")) + ) + + out.toString should equal ("not computable\n") + out.reset() + } + } + "no dashless argument" should throws { + "IllegalArgumentException" in { + evaluating { + refinedsoundexalgorithm.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala new file mode 100755 index 0000000..42338af --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala @@ -0,0 +1,46 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class refinedsoundexmetricSpec extends ScalaTest { + "refinedsoundexmetric" 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)( + refinedsoundexmetric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("true\n") + out.reset() + + Console.withOut(out)( + refinedsoundexmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("false\n") + out.reset() + + Console.withOut(out)( + refinedsoundexmetric.main(Array("--unitTest", "--debug", "1", "1")) + ) + + out.toString should equal ("not comparable\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + refinedsoundexmetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala new file mode 100755 index 0000000..f971d66 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala @@ -0,0 +1,39 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class soundexalgorithmSpec extends ScalaTest { + "soundexalgorithm" should provide { + "main method" when passed { + "valid dashless argument" should executes { + "print phonetic representation" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + soundexalgorithm.main(Array("--unitTest", "--debug", "abc")) + ) + + out.toString should equal ("a120\n") + out.reset() + + Console.withOut(out)( + soundexalgorithm.main(Array("--unitTest", "--debug", "1")) + ) + + out.toString should equal ("not computable\n") + out.reset() + } + } + "no dashless argument" should throws { + "IllegalArgumentException" in { + evaluating { + soundexalgorithm.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala new file mode 100755 index 0000000..82a3f6d --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala @@ -0,0 +1,46 @@ +package com.rockymadden.stringmetric.cli.phonetic + +import com.rockymadden.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class soundexmetricSpec extends ScalaTest { + "soundexmetric" 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)( + soundexmetric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("true\n") + out.reset() + + Console.withOut(out)( + soundexmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("false\n") + out.reset() + + Console.withOut(out)( + soundexmetric.main(Array("--unitTest", "--debug", "1", "1")) + ) + + out.toString should equal ("not comparable\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + soundexmetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala new file mode 100755 index 0000000..db68b68 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala @@ -0,0 +1,39 @@ +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 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] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala new file mode 100755 index 0000000..28e91ad --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala @@ -0,0 +1,39 @@ +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 hammingmetricSpec extends ScalaTest { + "hammingmetric" 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)( + hammingmetric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("0\n") + out.reset() + + Console.withOut(out)( + hammingmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("3\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + hammingmetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala new file mode 100755 index 0000000..9f7e2b9 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala @@ -0,0 +1,39 @@ +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 jaccardmetricSpec extends ScalaTest { + "jaccardmetric" 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)( + jaccardmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc")) + ) + + out.toString should equal ("1.0\n") + out.reset() + + Console.withOut(out)( + jaccardmetric.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 { + jaccardmetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala new file mode 100755 index 0000000..980ecff --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala @@ -0,0 +1,39 @@ +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 jarometricSpec extends ScalaTest { + "jarometric" should provide { + "main method" when passed { + "valid dashless arguments" should executes { + "print the distance" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + jarometric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("1.0\n") + out.reset() + + Console.withOut(out)( + jarometric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("0.0\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + jarometric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala new file mode 100755 index 0000000..d84f1a5 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala @@ -0,0 +1,39 @@ +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 jarowinklermetricSpec extends ScalaTest { + "jarowinklermetric" should provide { + "main method" when passed { + "valid dashless arguments" should executes { + "print the distance" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + jarowinklermetric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("1.0\n") + out.reset() + + Console.withOut(out)( + jarowinklermetric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("0.0\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + jarowinklermetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala new file mode 100755 index 0000000..ec4c8a7 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala @@ -0,0 +1,39 @@ +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 levenshteinmetricSpec extends ScalaTest { + "levenshteinmetric" 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)( + levenshteinmetric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("0\n") + out.reset() + + Console.withOut(out)( + levenshteinmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("3\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + levenshteinmetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala new file mode 100755 index 0000000..f969df3 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala @@ -0,0 +1,68 @@ +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 ngrammetricSpec extends ScalaTest { + "ngrammetric" should provide { + "main method" when passed { + "valid dashless arguments and valid n argument" should executes { + "print if they are a match" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + ngrammetric.main( + Array( + "--unitTest", + "--debug", + "--n=1", + "abc", + "abc" + ) + ) + ) + + out.toString should equal ("1.0\n") + out.reset() + + Console.withOut(out)( + ngrammetric.main( + Array( + "--unitTest", + "--debug", + "--n=1", + "abc", + "xyz" + ) + ) + ) + + out.toString should equal ("0.0\n") + out.reset() + } + } + "valid dashless arguments and invalid n argument" should throws { + "IllegalArgumentException" in { + evaluating { + ngrammetric.main( + Array( + "--unitTest", + "abc", + "abc" + ) + ) + } should produce [IllegalArgumentException] + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + ngrammetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala new file mode 100755 index 0000000..d614a77 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala @@ -0,0 +1,39 @@ +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 overlapmetricSpec extends ScalaTest { + "overlapmetric" 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)( + overlapmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc")) + ) + + out.toString should equal ("1.0\n") + out.reset() + + Console.withOut(out)( + overlapmetric.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 { + overlapmetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala new file mode 100755 index 0000000..8af7793 --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala @@ -0,0 +1,39 @@ +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 ratcliffobershelpmetricSpec extends ScalaTest { + "ratcliffobershelpmetric" 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)( + ratcliffobershelpmetric.main(Array("--unitTest", "--debug", "abc", "abc")) + ) + + out.toString should equal ("1.0\n") + out.reset() + + Console.withOut(out)( + ratcliffobershelpmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) + ) + + out.toString should equal ("0.0\n") + out.reset() + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + ratcliffobershelpmetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala new file mode 100755 index 0000000..41065db --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala @@ -0,0 +1,123 @@ +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 weightedlevenshteinmetricSpec extends ScalaTest { + "weightedlevenshteinmetric" should provide { + "main method" when passed { + "valid dashless arguments and valid weight arguments" should executes { + "print if they are a match" in { + val out = new java.io.ByteArrayOutputStream() + + Console.withOut(out)( + weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=1", + "--insertWeight=1", + "--substituteWeight=1", + "abc", + "abc" + ) + ) + ) + + out.toString should equal ("0.0\n") + out.reset() + + Console.withOut(out)( + weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=2", + "--insertWeight=2", + "--substituteWeight=1", + "abc", + "xyz" + ) + ) + ) + + out.toString should equal ("3.0\n") + out.reset() + + Console.withOut(out)( + weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=2", + "--insertWeight=1", + "--substituteWeight=2", + "xyz", + "xyzxyz" + ) + ) + ) + + out.toString should equal ("3.0\n") + out.reset() + + Console.withOut(out)( + weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=1", + "--insertWeight=2", + "--substituteWeight=2", + "xyzxyz", + "xyz" + ) + ) + ) + + out.toString should equal ("3.0\n") + out.reset() + } + } + "valid dashless arguments and invalid weight arguments" should throws { + "IllegalArgumentException" in { + evaluating { + weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=1", + "--substituteWeight=1", + "abc", + "abc" + ) + ) + } should produce [IllegalArgumentException] + + evaluating { + weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=1", + "--insertWeight=q", + "--substituteWeight=1", + "abc", + "abc" + ) + ) + } should produce [IllegalArgumentException] + } + } + "no dashless arguments" should throws { + "IllegalArgumentException" in { + evaluating { + weightedlevenshteinmetric.main(Array("--unitTest", "--debug")) + } should produce [IllegalArgumentException] + } + } + } + } +} diff --git a/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenization/ngramtokenizerSpec.scala b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenization/ngramtokenizerSpec.scala new file mode 100755 index 0000000..8a1ea1d --- /dev/null +++ b/stringmetric-cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenization/ngramtokenizerSpec.scala @@ -0,0 +1,66 @@ +package com.rockymadden.stringmetric.cli.tokenization + +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] + } + } + } + } +} |