diff options
author | Rocky Madden <git@rockymadden.com> | 2014-01-06 13:58:07 -0700 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2014-01-06 13:58:07 -0700 |
commit | a6e907a0532d50f3fda44109d0c0fe1a15b40134 (patch) | |
tree | 30898fa2afe71cbfa52b3e54fd837b455b509ccc | |
parent | fa6545a0f828112adf61d97edb58b24dd8bc3693 (diff) | |
download | stringmetric-a6e907a0532d50f3fda44109d0c0fe1a15b40134.tar.gz stringmetric-a6e907a0532d50f3fda44109d0c0fe1a15b40134.tar.bz2 stringmetric-a6e907a0532d50f3fda44109d0c0fe1a15b40134.zip |
Moved from scalatest to specs2.
27 files changed, 1489 insertions, 1862 deletions
diff --git a/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala index b95046d..15110dd 100644 --- a/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala @@ -1,43 +1,42 @@ package com.rockymadden.stringmetric -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class AlgorithmSpec extends ScalaTest { +object AlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { import phonetic._ import Algorithm._ import Transform._ - "StringAlgorithm" should provide { - "compute method and companion object pass through" in { - StringAlgorithm.computeWithMetaphone("testone").get should - equal (MetaphoneAlgorithm.compute("testone".toCharArray).get) - StringAlgorithm.computeWithNysiis("testone").get should - equal (NysiisAlgorithm.compute("testone".toCharArray).get) - StringAlgorithm.computeWithRefinedNysiis("testone").get should - equal (RefinedNysiisAlgorithm.compute("testone".toCharArray).get) - StringAlgorithm.computeWithRefinedSoundex("testone").get should - equal (RefinedSoundexAlgorithm.compute("testone".toCharArray).get) - StringAlgorithm.computeWithSoundex("testone").get should - equal (SoundexAlgorithm.compute("testone".toCharArray).get) + "StringAlgorithm convenience methods" should { + "pass through" in { + StringAlgorithm.computeWithMetaphone("testone").get must + beEqualTo(MetaphoneAlgorithm.compute("testone".toCharArray).get) + StringAlgorithm.computeWithNysiis("testone").get must + beEqualTo(NysiisAlgorithm.compute("testone".toCharArray).get) + StringAlgorithm.computeWithRefinedNysiis("testone").get must + beEqualTo(RefinedNysiisAlgorithm.compute("testone".toCharArray).get) + StringAlgorithm.computeWithRefinedSoundex("testone").get must + beEqualTo(RefinedSoundexAlgorithm.compute("testone".toCharArray).get) + StringAlgorithm.computeWithSoundex("testone").get must + beEqualTo(SoundexAlgorithm.compute("testone".toCharArray).get) } } - "StringAlgorithmDecorator" should provide { - "withMemoization()" in { + "StringAlgorithmDecorator withMemoization()" should { + "memoize" in { val memo = MetaphoneAlgorithm withMemoization (0 until 1000000) foreach { i => memo.compute("abc123") memo.compute("abc456") } + + true must beTrue } + } - "withTransform()" in { - (MetaphoneAlgorithm withTransform StringTransform.filterAlpha).compute("abc123").get should - equal (MetaphoneAlgorithm.compute("abc").get) + "StringAlgorithmDecorator withTransform()" should { + "transform" in { + (MetaphoneAlgorithm withTransform StringTransform.filterAlpha).compute("abc123").get must + beEqualTo(MetaphoneAlgorithm.compute("abc").get) } } } - diff --git a/core/src/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala index 5a6a1dc..43e5d80 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala @@ -1,95 +1,36 @@ package com.rockymadden.stringmetric -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class AlphabetSpec extends ScalaTest { "Alphabet" should provide { +object AlphabetSpec extends org.specs2.mutable.SpecificationWithJUnit { import Alphabet.{Alpha, Vowel} - "an overloaded isSuperset method which accepts Char" when passed { - "non-alphabet argument" should returns { - "false" in { - Alpha isSuperset '0' should be (false) - } - } - "alphabet argument" should returns { - "true" in { - Alpha isSuperset 'a' should be (true) - Alpha isSuperset 'A' should be (true) - } - } - "non-vowel argument" should returns { - "false" in { - Vowel isSuperset 'y' should be (false) - } - } - "vowel argument" should returns { - "true" in { - Vowel isSuperset 'a' should be (true) - Vowel isSuperset 'A' should be (true) - } - } - } - "an overloaded isSuperset method which accepts Array[Char]" when passed { - "empty argument" should returns { - "false" in { - Alpha isSuperset Array.empty[Char] should be (false) - } - } - "non-alphabet argument" should returns { - "false" in { - Alpha isSuperset "hi!".toCharArray should be (false) - Alpha isSuperset "helloworld!".toCharArray should be (false) - } - } - "alphabet argument" should returns { - "true" in { - Alpha isSuperset "hi".toCharArray should be (true) - Alpha isSuperset "helloworld".toCharArray should be (true) - Alpha isSuperset "HI".toCharArray should be (true) - Alpha isSuperset "HELLOWORLD".toCharArray should be (true) - } - } - "non-vowel argument" should returns { - "false" in { - Vowel isSuperset "y".toCharArray should be (false) - } - } - "vowel argument" should returns { - "true" in { - Vowel isSuperset "a".toCharArray should be (true) - Vowel isSuperset "A".toCharArray should be (true) - } - } - } - "an overloaded isSuperset method which accepts String" when passed { - "empty argument" should returns { - "false" in { - Alpha isSuperset "" should be (false) - } - } - "non-alphabet argument" should returns { - "false" in { - Alpha isSuperset "helloworld!" should be (false) - } - } - "alphabet argument" should returns { - "true" in { - Alpha isSuperset "helloworld" should be (true) - Alpha isSuperset "HELLOWORLD" should be (true) - } - } - "non-vowel argument" should returns { - "false" in { - Vowel isSuperset "y" should be (false) - } - } - "vowel argument" should returns { - "true" in { - Vowel isSuperset "a" should be (true) - Vowel isSuperset "A" should be (true) - } + "AlphabetSet isSuperset()" should { + "return false with non-alphabet argument" in { + Alpha isSuperset '0' must beFalse + Alpha isSuperset Array.empty[Char] must beFalse + Alpha isSuperset "helloworld!".toCharArray must beFalse + Alpha isSuperset "" must beFalse + Alpha isSuperset "helloworld!" must beFalse + } + "return true with alphabet argument" in { + Alpha isSuperset 'a' must beTrue + Alpha isSuperset 'A' must beTrue + Alpha isSuperset "helloworld".toCharArray must beTrue + Alpha isSuperset "HELLOWORLD".toCharArray must beTrue + Alpha isSuperset "helloworld" must beTrue + Alpha isSuperset "HELLOWORLD" must beTrue + } + "return false with non-vowel argument" in { + Vowel isSuperset 'y' must beFalse + Vowel isSuperset "y".toCharArray must beFalse + Vowel isSuperset "y" must beFalse + } + "return true with vowel argument" in { + Vowel isSuperset 'a' must beTrue + Vowel isSuperset 'A' must beTrue + Vowel isSuperset "a".toCharArray must beTrue + Vowel isSuperset "A".toCharArray must beTrue + Vowel isSuperset "a" must beTrue + Vowel isSuperset "A" must beTrue } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/MetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/MetricSpec.scala index f821226..a72889e 100644 --- a/core/src/test/scala/com/rockymadden/stringmetric/MetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/MetricSpec.scala @@ -1,65 +1,63 @@ package com.rockymadden.stringmetric -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class MetricSpec extends ScalaTest { +object MetricSpec extends org.specs2.mutable.SpecificationWithJUnit { import phonetic._ import similarity._ import Metric._ import Transform._ - "StringMetric standalone object" should provide { - "compare method and companion object pass through" in { - StringMetric.compareWithDiceSorensen(1)("testone", "testtwo").get should - equal (DiceSorensenMetric(1).compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithHamming("testone", "testtwo").get should - equal (HammingMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithJaccard(1)("testone", "testtwo").get should - equal (JaccardMetric(1).compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithJaro("testone", "testtwo").get should - equal (JaroMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithJaroWinkler("testone", "testtwo").get should - equal (JaroWinklerMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithLevenshtein("testone", "testtwo").get should - equal (LevenshteinMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithMetaphone("testone", "testtwo").get should - equal (MetaphoneMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithNGram(1)("testone", "testtwo").get should - equal (NGramMetric(1).compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithNysiis("testone", "testtwo").get should - equal (NysiisMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithOverlap(1)("testone", "testtwo").get should - equal (OverlapMetric(1).compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithRefinedNysiis("testone", "testtwo").get should - equal (RefinedNysiisMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithRefinedSoundex("testone", "testtwo").get should - equal (RefinedSoundexMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithSoundex("testone", "testtwo").get should - equal (SoundexMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) - StringMetric.compareWithWeightedLevenshtein(1, 2, 3)("testone", "testtwo").get should - equal (WeightedLevenshteinMetric(1, 2, 3).compare("testone".toCharArray, "testtwo".toCharArray).get) + "StringMetric convenience methods" should { + "pass through" in { + StringMetric.compareWithDiceSorensen(1)("testone", "testtwo").get must + beEqualTo(DiceSorensenMetric(1).compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithHamming("testone", "testtwo").get must + beEqualTo(HammingMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithJaccard(1)("testone", "testtwo").get must + beEqualTo(JaccardMetric(1).compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithJaro("testone", "testtwo").get must + beEqualTo(JaroMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithJaroWinkler("testone", "testtwo").get must + beEqualTo(JaroWinklerMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithLevenshtein("testone", "testtwo").get must + beEqualTo(LevenshteinMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithMetaphone("testone", "testtwo").get must + beEqualTo(MetaphoneMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithNGram(1)("testone", "testtwo").get must + beEqualTo(NGramMetric(1).compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithNysiis("testone", "testtwo").get must + beEqualTo(NysiisMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithOverlap(1)("testone", "testtwo").get must + beEqualTo(OverlapMetric(1).compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithRefinedNysiis("testone", "testtwo").get must + beEqualTo(RefinedNysiisMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithRefinedSoundex("testone", "testtwo").get must + beEqualTo(RefinedSoundexMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithSoundex("testone", "testtwo").get must + beEqualTo(SoundexMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + StringMetric.compareWithWeightedLevenshtein(1, 2, 3)("testone", "testtwo").get must + beEqualTo(WeightedLevenshteinMetric(1, 2, 3).compare("testone".toCharArray, "testtwo".toCharArray).get) } } - "StringMetricDecorator" should provide { - "withMemoization()" in { + "StringMetricDecorator withMemoization()" should { + "memoize" in { val memo = MetaphoneMetric withMemoization (0 until 1000000) foreach { i => memo.compare("abc123", "abc456") memo.compare("abc456", "abc123") } - } - "withTransform()" in { - (MetaphoneMetric withTransform StringTransform.filterAlpha).compare("abc123", "abc456").get should - equal (true) - (DiceSorensenMetric(1) withTransform StringTransform.filterAlpha).compare("abc123", "abc456").get should - equal (1.0) + true must beTrue + } + } - (MetaphoneMetric withTransform (StringTransform.filterAlpha andThen StringTransform.filterUpperCase)).compare("abc123", "abc456") + "StringMetricDecorator withTransform()" should { + "transform" in { + (MetaphoneMetric withTransform StringTransform.filterAlpha).compare("abc123", "abc456").get must + beEqualTo(true) + (DiceSorensenMetric(1) withTransform StringTransform.filterAlpha).compare("abc123", "abc456").get must + beEqualTo(1.0) } } } diff --git a/core/src/test/scala/com/rockymadden/stringmetric/ScalaTest.scala b/core/src/test/scala/com/rockymadden/stringmetric/ScalaTest.scala deleted file mode 100755 index 5f4ab62..0000000 --- a/core/src/test/scala/com/rockymadden/stringmetric/ScalaTest.scala +++ /dev/null @@ -1,18 +0,0 @@ -package com.rockymadden.stringmetric - -import org.scalatest.{BeforeAndAfter, ParallelTestExecution, WordSpec} -import org.scalatest.matchers.ShouldMatchers - -trait ScalaTest extends WordSpec with ShouldMatchers with BeforeAndAfter with ParallelTestExecution { - def allows = afterWord("allow") - - def executes = afterWord("execute") - - def passed = afterWord("passed") - - def provide = afterWord("provide") - - def returns = afterWord("return") - - def throws = afterWord("throw") -} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/TokenizeSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/TokenizeSpec.scala index cfba0f7..c133c66 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/TokenizeSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/TokenizeSpec.scala @@ -1,45 +1,35 @@ package com.rockymadden.stringmetric -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class TokenizeSpec extends ScalaTest { "NGramTokenizer" should provide { +object TokenizeSpec extends org.specs2.mutable.SpecificationWithJUnit { import Tokenize._ - "tokenize method" when passed { - "empty argument" should returns { - "None" in { - NGramTokenizer(1).tokenize("").isDefined should be (false) - } + "NGramTokenizer tokenize()" should { + "return None with empty argument" in { + NGramTokenizer(1).tokenize("").isDefined must beEqualTo(false) } - "invalid n argument" should returns { - "None" in { - NGramTokenizer(0).tokenize("").isDefined should be (false) - NGramTokenizer(-1).tokenize("").isDefined should be (false) - } + "return None with invalid n argument" in { + NGramTokenizer(0).tokenize("").isDefined must beEqualTo(false) + NGramTokenizer(-1).tokenize("").isDefined must beEqualTo(false) } - "valid argument" should returns { - "Array[String]" in { - NGramTokenizer(1).tokenize("abcdefghijklmnopqrstuvwxyz").get should equal ( - Array( - "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", - "s", "t", "u", "v", "w", "x", "y", "z" - ) + "return Array[String] with valid argument" in { + NGramTokenizer(1).tokenize("abcdefghijklmnopqrstuvwxyz").get must beEqualTo( + Array( + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", + "s", "t", "u", "v", "w", "x", "y", "z" ) - NGramTokenizer(2).tokenize("abcdefghijklmnopqrstuvwxyz").get should equal ( - Array( - "ab", "bc", "cd", "de", "ef", "fg", "gh", "hi", "ij", "jk", "kl", "lm", "mn", "no", "op", - "pq", "qr", "rs", "st", "tu", "uv", "vw", "wx", "xy", "yz" - ) + ) + NGramTokenizer(2).tokenize("abcdefghijklmnopqrstuvwxyz").get must beEqualTo( + Array( + "ab", "bc", "cd", "de", "ef", "fg", "gh", "hi", "ij", "jk", "kl", "lm", "mn", "no", "op", + "pq", "qr", "rs", "st", "tu", "uv", "vw", "wx", "xy", "yz" ) - NGramTokenizer(3).tokenize("abcdefghijklmnopqrstuvwxyz").get should equal ( - Array( - "abc", "bcd", "cde", "def", "efg", "fgh", "ghi", "hij", "ijk", "jkl", "klm", "lmn", "mno", - "nop", "opq", "pqr", "qrs", "rst", "stu", "tuv", "uvw", "vwx", "wxy", "xyz" - ) + ) + NGramTokenizer(3).tokenize("abcdefghijklmnopqrstuvwxyz").get must beEqualTo( + Array( + "abc", "bcd", "cde", "def", "efg", "fgh", "ghi", "hij", "ijk", "jkl", "klm", "lmn", "mno", + "nop", "opq", "pqr", "qrs", "rst", "stu", "tuv", "uvw", "vwx", "wxy", "xyz" ) - } + ) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/TransformSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/TransformSpec.scala index 5e79c62..c9c5029 100644 --- a/core/src/test/scala/com/rockymadden/stringmetric/TransformSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/TransformSpec.scala @@ -1,181 +1,159 @@ package com.rockymadden.stringmetric -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class TransformSpec extends ScalaTest { "StringTransform" should provide { +object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit { import Transform._ - "filterAlpha()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterAlpha( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ("aBc".toCharArray) - } - } - } - "filterNotAlpha()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterNotAlpha( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ( - ("123" + 0x250.toChar).toCharArray - ) - } - } - } - "filterAlphaNumeric()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterAlphaNumeric( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ("aBc123".toCharArray) - } - } - } - "filterNotAlphaNumeric()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterNotAlphaNumeric( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ( - ("" + 0x250.toChar).toCharArray - ) - } - } - } - "filterAscii()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterAscii( - ("aBc" + 0x80.toChar).toCharArray - ) should equal ("aBc".toCharArray) - } - } - } - "filterNotAscii()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterNotAscii( - ("aBc" + 0x100.toChar).toCharArray - ) should equal ( - ("" + 0x100.toChar).toCharArray - ) - } - } - } - "filterExtendedAscii()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterExtendedAscii( - ("aBc" + 0x100.toChar).toCharArray - ) should equal ("aBc".toCharArray) - } - } - } - "filterNotExtendedAscii()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterNotExtendedAscii( - ("aBc" + 0x250.toChar).toCharArray - ) should equal ( - ("" + 0x250.toChar).toCharArray - ) - } - } - } - "filterLatin()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterLatin( - ("aBc" + 0x250.toChar).toCharArray - ) should equal ("aBc".toCharArray) - } - } - } - "filterNotLatin()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterNotLatin( - ("aBc" + 0x300.toChar).toCharArray - ) should equal ( - ("" + 0x300.toChar).toCharArray - ) - } - } - } - "filterLowerCase()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterLowerCase( - "aBc123" + 0x250.toChar - ) should equal ("ac".toCharArray) - } - } - } - "filterNotLowerCase()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterNotLowerCase( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ( - ("B123" + 0x250.toChar).toCharArray - ) - } - } - } - "filterNumeric()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterNumeric( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ("123".toCharArray) - } - } - } - "filterNotNumeric()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterNotNumeric( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ( - ("aBc" + 0x250.toChar).toCharArray - ) - } - } - } - "filterUpperCase()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterUpperCase( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ("B".toCharArray) - } - } - } - "filterNotUpperCase()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.filterNotUpperCase( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ( - ("ac123" + 0x250.toChar).toCharArray - ) - } - } - } - "ignoreAlphaCase()" when passed { - "String" should returns { - "transformed String" in { - StringTransform.ignoreAlphaCase( - ("aBc123" + 0x250.toChar).toCharArray - ) should equal ( - ("abc123" + 0x250.toChar).toCharArray - ) - } - } - } -}} + "StringTransform filterAlpha()" should { + "return transformed" in { + StringTransform.filterAlpha( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo("aBc".toCharArray) + } + } + + "StringTransform filterNotAlpha()" should { + "return transformed" in { + StringTransform.filterNotAlpha( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo( + ("123" + 0x250.toChar).toCharArray + ) + } + } + + "StringTransform filterAlphaNumeric()" should { + "return transformed" in { + StringTransform.filterAlphaNumeric( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo("aBc123".toCharArray) + } + } + + "StringTransform filterNotAlphaNumeric()" should { + "return transformed" in { + StringTransform.filterNotAlphaNumeric( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo( + ("" + 0x250.toChar).toCharArray + ) + } + } + + "StringTransform filterAscii()" should { + "return transformed" in { + StringTransform.filterAscii( + ("aBc" + 0x80.toChar).toCharArray + ) must beEqualTo("aBc".toCharArray) + } + } + + "StringTransform filterNotAscii()" should { + "return transformed" in { + StringTransform.filterNotAscii( + ("aBc" + 0x100.toChar).toCharArray + ) must beEqualTo( + ("" + 0x100.toChar).toCharArray + ) + } + } + + "StringTransform filterExtendedAscii()" should { + "return transformed" in { + StringTransform.filterExtendedAscii( + ("aBc" + 0x100.toChar).toCharArray + ) must beEqualTo("aBc".toCharArray) + } + } + + "StringTransform filterNotExtendedAscii()" should { + "return transformed" in { + StringTransform.filterNotExtendedAscii( + ("aBc" + 0x250.toChar).toCharArray + ) must beEqualTo( + ("" + 0x250.toChar).toCharArray + ) + } + } + + "StringTransform filterLatin()" should { + "return transformed" in { + StringTransform.filterLatin( + ("aBc" + 0x250.toChar).toCharArray + ) must beEqualTo("aBc".toCharArray) + } + } + + "StringTransform filterNotLatin()" should { + "return transformed" in { + StringTransform.filterNotLatin( + ("aBc" + 0x300.toChar).toCharArray + ) must beEqualTo( + ("" + 0x300.toChar).toCharArray + ) + } + } + + "StringTransform filterLowerCase()" should { + "return transformed" in { + StringTransform.filterLowerCase( + "aBc123" + 0x250.toChar + ) must beEqualTo("ac".toCharArray) + } + } + + "StringTransform filterNotLowerCase()" should { + "return transformed" in { + StringTransform.filterNotLowerCase( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo( + ("B123" + 0x250.toChar).toCharArray + ) + } + } + + "StringTransform filterNumeric()" should { + "return transformed" in { + StringTransform.filterNumeric( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo("123".toCharArray) + } + } + + "StringTransform filterNotNumeric()" should { + "return transformed" in { + StringTransform.filterNotNumeric( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo( + ("aBc" + 0x250.toChar).toCharArray + ) + } + } + + "StringTransform filterUpperCase()" should { + "return transformed" in { + StringTransform.filterUpperCase( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo("B".toCharArray) + } + } + + "StringTransform filterNotUpperCase()" should { + "return transformed" in { + StringTransform.filterNotUpperCase( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo( + ("ac123" + 0x250.toChar).toCharArray + ) + } + } + + "StringTransform ignoreAlphaCase()" should { + "return transformed" in { + StringTransform.ignoreAlphaCase( + ("aBc123" + 0x250.toChar).toCharArray + ) must beEqualTo( + ("abc123" + 0x250.toChar).toCharArray + ) + } + } +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala index 6f56b6d..5b9f078 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala @@ -1,211 +1,200 @@ package com.rockymadden.stringmetric.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 { - "compute method" when passed { - "empty argument" should returns { - "None" in { - MetaphoneAlgorithm.compute("").isDefined should be (false) - } +object MetaphoneAlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "MetaphoneAlgorithm compute()" should { + "return None with empty argument" in { + MetaphoneAlgorithm.compute("").isDefined must beFalse } - "non-phonetic argument" should returns { - "None" in { - MetaphoneAlgorithm.compute("123").isDefined should be (false) - } + "return None with non-phonetic argument" in { + MetaphoneAlgorithm.compute("123").isDefined must beFalse } - "phonetic argument" should returns { - "Some" in { - // z - MetaphoneAlgorithm.compute("z").get should equal ("s") - MetaphoneAlgorithm.compute("zz").get should equal ("s") - - // y - MetaphoneAlgorithm.compute("y").isDefined should be (false) - MetaphoneAlgorithm.compute("zy").get should equal ("s") - MetaphoneAlgorithm.compute("zyz").get should equal ("ss") - MetaphoneAlgorithm.compute("zya").get should equal ("sy") - - // x - MetaphoneAlgorithm.compute("x").get should equal ("s") - MetaphoneAlgorithm.compute("zx").get should equal ("sks") - MetaphoneAlgorithm.compute("zxz").get should equal ("skss") - - // w - MetaphoneAlgorithm.compute("w").isDefined should be (false) - MetaphoneAlgorithm.compute("zw").get should equal ("s") - MetaphoneAlgorithm.compute("zwz").get should equal ("ss") - MetaphoneAlgorithm.compute("zwa").get should equal ("sw") - - // v - MetaphoneAlgorithm.compute("v").get should equal ("f") - MetaphoneAlgorithm.compute("zv").get should equal ("sf") - MetaphoneAlgorithm.compute("zvz").get should equal ("sfs") - - // u - MetaphoneAlgorithm.compute("u").get should equal ("u") - MetaphoneAlgorithm.compute("zu").get should equal ("s") - - // t - MetaphoneAlgorithm.compute("t").get should equal ("t") - MetaphoneAlgorithm.compute("ztiaz").get should equal ("sxs") - MetaphoneAlgorithm.compute("ztioz").get should equal ("sxs") - MetaphoneAlgorithm.compute("zthz").get should equal ("s0s") - MetaphoneAlgorithm.compute("ztchz").get should equal ("sxs") - MetaphoneAlgorithm.compute("ztz").get should equal ("sts") - - // s - MetaphoneAlgorithm.compute("s").get should equal ("s") - MetaphoneAlgorithm.compute("zshz").get should equal ("sxs") - MetaphoneAlgorithm.compute("zsioz").get should equal ("sxs") - MetaphoneAlgorithm.compute("zsiaz").get should equal ("sxs") - MetaphoneAlgorithm.compute("zs").get should equal ("ss") - MetaphoneAlgorithm.compute("zsz").get should equal ("sss") - - // r - MetaphoneAlgorithm.compute("r").get should equal ("r") - MetaphoneAlgorithm.compute("zr").get should equal ("sr") - MetaphoneAlgorithm.compute("zrz").get should equal ("srs") - - // q - MetaphoneAlgorithm.compute("q").get should equal ("k") - MetaphoneAlgorithm.compute("zq").get should equal ("sk") - MetaphoneAlgorithm.compute("zqz").get should equal ("sks") - - // p - MetaphoneAlgorithm.compute("p").get should equal ("p") - MetaphoneAlgorithm.compute("zp").get should equal ("sp") - MetaphoneAlgorithm.compute("zph").get should equal ("sf") - MetaphoneAlgorithm.compute("zpz").get should equal ("sps") - - // o - MetaphoneAlgorithm.compute("o").get should equal ("o") - MetaphoneAlgorithm.compute("zo").get should equal ("s") - - // n - MetaphoneAlgorithm.compute("n").get should equal ("n") - MetaphoneAlgorithm.compute("zn").get should equal ("sn") - MetaphoneAlgorithm.compute("znz").get should equal ("sns") - - // m - MetaphoneAlgorithm.compute("m").get should equal ("m") - MetaphoneAlgorithm.compute("zm").get should equal ("sm") - MetaphoneAlgorithm.compute("zmz").get should equal ("sms") - - // l - MetaphoneAlgorithm.compute("l").get should equal ("l") - MetaphoneAlgorithm.compute("zl").get should equal ("sl") - MetaphoneAlgorithm.compute("zlz").get should equal ("sls") - - // k - MetaphoneAlgorithm.compute("k").get should equal ("k") - MetaphoneAlgorithm.compute("zk").get should equal ("sk") - MetaphoneAlgorithm.compute("zck").get should equal ("sk") - - // j - MetaphoneAlgorithm.compute("j").get should equal ("j") - MetaphoneAlgorithm.compute("zj").get should equal ("sj") - MetaphoneAlgorithm.compute("zjz").get should equal ("sjs") - - // i - MetaphoneAlgorithm.compute("i").get should equal ("i") - MetaphoneAlgorithm.compute("zi").get should equal ("s") - - // h - MetaphoneAlgorithm.compute("h").get should equal ("h") // php wrongly says nothing - MetaphoneAlgorithm.compute("zh").get should equal ("sh") // php wrongly says s - MetaphoneAlgorithm.compute("zah").get should equal ("s") - MetaphoneAlgorithm.compute("zchh").get should equal ("sx") - MetaphoneAlgorithm.compute("ha").get should equal ("h") - - // g - MetaphoneAlgorithm.compute("g").get should equal ("k") - MetaphoneAlgorithm.compute("zg").get should equal ("sk") - MetaphoneAlgorithm.compute("zgh").get should equal ("skh") // php wrongly says sf - MetaphoneAlgorithm.compute("zghz").get should equal ("shs") // php wrongly says sfs - MetaphoneAlgorithm.compute("zgha").get should equal ("sh") // php wrongly says sf others wrongly say skh - MetaphoneAlgorithm.compute("zgn").get should equal ("sn") - MetaphoneAlgorithm.compute("zgns").get should equal ("skns") - MetaphoneAlgorithm.compute("zgned").get should equal ("snt") // others wrongly says sknt - MetaphoneAlgorithm.compute("zgneds").get should equal ("sknts") // php wrongly says snts - MetaphoneAlgorithm.compute("zgi").get should equal ("sj") - MetaphoneAlgorithm.compute("zgiz").get should equal ("sjs") - MetaphoneAlgorithm.compute("zge").get should equal ("sj") - MetaphoneAlgorithm.compute("zgez").get should equal ("sjs") - MetaphoneAlgorithm.compute("zgy").get should equal ("sj") - MetaphoneAlgorithm.compute("zgyz").get should equal ("sjs") - MetaphoneAlgorithm.compute("zgz").get should equal ("sks") - - // f - MetaphoneAlgorithm.compute("f").get should equal ("f") - MetaphoneAlgorithm.compute("zf").get should equal ("sf") - MetaphoneAlgorithm.compute("zfz").get should equal ("sfs") - - // e - MetaphoneAlgorithm.compute("e").get should equal ("e") - MetaphoneAlgorithm.compute("ze").get should equal ("s") - - // d - MetaphoneAlgorithm.compute("d").get should equal ("t") - MetaphoneAlgorithm.compute("fudge").get should equal ("fjj") // php wrongly says fj - MetaphoneAlgorithm.compute("dodgy").get should equal ("tjj") // php wrongly says tj others wrongly say tjjy - MetaphoneAlgorithm.compute("dodgi").get should equal ("tjj") // php wrongly says tj - MetaphoneAlgorithm.compute("zd").get should equal ("st") - MetaphoneAlgorithm.compute("zdz").get should equal ("sts") - - // c - MetaphoneAlgorithm.compute("c").get should equal ("k") - MetaphoneAlgorithm.compute("zcia").get should equal ("sx") - MetaphoneAlgorithm.compute("zciaz").get should equal ("sxs") - MetaphoneAlgorithm.compute("zch").get should equal ("sx") - MetaphoneAlgorithm.compute("zchz").get should equal ("sxs") - MetaphoneAlgorithm.compute("zci").get should equal ("ss") - MetaphoneAlgorithm.compute("zciz").get should equal ("sss") - MetaphoneAlgorithm.compute("zce").get should equal ("ss") - MetaphoneAlgorithm.compute("zcez").get should equal ("sss") - MetaphoneAlgorithm.compute("zcy").get should equal ("ss") - MetaphoneAlgorithm.compute("zcyz").get should equal ("sss") - MetaphoneAlgorithm.compute("zsci").get should equal ("ss") - MetaphoneAlgorithm.compute("zsciz").get should equal ("sss") - MetaphoneAlgorithm.compute("zsce").get should equal ("ss") - MetaphoneAlgorithm.compute("zscez").get should equal ("sss") - MetaphoneAlgorithm.compute("zscy").get should equal ("ss") - MetaphoneAlgorithm.compute("zscyz").get should equal ("sss") - MetaphoneAlgorithm.compute("zsch").get should equal ("sskh") // php wrongly says ssx - MetaphoneAlgorithm.compute("zc").get should equal ("sk") - MetaphoneAlgorithm.compute("zcz").get should equal ("sks") - - // b - MetaphoneAlgorithm.compute("b").get should equal ("b") - MetaphoneAlgorithm.compute("zb").get should equal ("sb") - MetaphoneAlgorithm.compute("zbz").get should equal ("sbs") - MetaphoneAlgorithm.compute("zmb").get should equal ("sm") - - // a - MetaphoneAlgorithm.compute("a").get should equal ("a") - MetaphoneAlgorithm.compute("za").get should equal ("s") - - // Miscellaneous. - MetaphoneAlgorithm.compute("dumb").get should equal ("tm") - MetaphoneAlgorithm.compute("smith").get should equal ("sm0") - MetaphoneAlgorithm.compute("school").get should equal ("skhl") // php wrongly says sxl - MetaphoneAlgorithm.compute("merci").get should equal ("mrs") - MetaphoneAlgorithm.compute("cool").get should equal ("kl") - MetaphoneAlgorithm.compute("aebersold").get should equal ("ebrslt") - MetaphoneAlgorithm.compute("gnagy").get should equal ("nj") - MetaphoneAlgorithm.compute("knuth").get should equal ("n0") - MetaphoneAlgorithm.compute("pniewski").get should equal ("nsk") - MetaphoneAlgorithm.compute("wright").get should equal ("rht") // php wrongly says rft - MetaphoneAlgorithm.compute("phone").get should equal ("fn") - MetaphoneAlgorithm.compute("aggregate").get should equal ("akrkt") - MetaphoneAlgorithm.compute("accuracy").get should equal ("akkrs") - MetaphoneAlgorithm.compute("encyclopedia").get should equal ("ensklpt") - MetaphoneAlgorithm.compute("honorificabilitudinitatibus").get should equal ("hnrfkblttnttbs") - MetaphoneAlgorithm.compute("antidisestablishmentarianism").get should equal ("anttsstblxmntrnsm") - } + "return Some with phonetic argument" in { + // z + MetaphoneAlgorithm.compute("z").get must beEqualTo("s") + MetaphoneAlgorithm.compute("zz").get must beEqualTo("s") + + // y + MetaphoneAlgorithm.compute("y").isDefined must beFalse + MetaphoneAlgorithm.compute("zy").get must beEqualTo("s") + MetaphoneAlgorithm.compute("zyz").get must beEqualTo("ss") + MetaphoneAlgorithm.compute("zya").get must beEqualTo("sy") + + // x + MetaphoneAlgorithm.compute("x").get must beEqualTo("s") + MetaphoneAlgorithm.compute("zx").get must beEqualTo("sks") + MetaphoneAlgorithm.compute("zxz").get must beEqualTo("skss") + + // w + MetaphoneAlgorithm.compute("w").isDefined must beFalse + MetaphoneAlgorithm.compute("zw").get must beEqualTo("s") + MetaphoneAlgorithm.compute("zwz").get must beEqualTo("ss") + MetaphoneAlgorithm.compute("zwa").get must beEqualTo("sw") + + // v + MetaphoneAlgorithm.compute("v").get must beEqualTo("f") + MetaphoneAlgorithm.compute("zv").get must beEqualTo("sf") + MetaphoneAlgorithm.compute("zvz").get must beEqualTo("sfs") + + // u + MetaphoneAlgorithm.compute("u").get must beEqualTo("u") + MetaphoneAlgorithm.compute("zu").get must beEqualTo("s") + + // t + MetaphoneAlgorithm.compute("t").get must beEqualTo("t") + MetaphoneAlgorithm.compute("ztiaz").get must beEqualTo("sxs") + MetaphoneAlgorithm.compute("ztioz").get must beEqualTo("sxs") + MetaphoneAlgorithm.compute("zthz").get must beEqualTo("s0s") + MetaphoneAlgorithm.compute("ztchz").get must beEqualTo("sxs") + MetaphoneAlgorithm.compute("ztz").get must beEqualTo("sts") + + // s + MetaphoneAlgorithm.compute("s").get must beEqualTo("s") + MetaphoneAlgorithm.compute("zshz").get must beEqualTo("sxs") + MetaphoneAlgorithm.compute("zsioz").get must beEqualTo("sxs") + MetaphoneAlgorithm.compute("zsiaz").get must beEqualTo("sxs") + MetaphoneAlgorithm.compute("zs").get must beEqualTo("ss") + MetaphoneAlgorithm.compute("zsz").get must beEqualTo("sss") + + // r + MetaphoneAlgorithm.compute("r").get must beEqualTo("r") + MetaphoneAlgorithm.compute("zr").get must beEqualTo("sr") + MetaphoneAlgorithm.compute("zrz").get must beEqualTo("srs") + + // q + MetaphoneAlgorithm.compute("q").get must beEqualTo("k") + MetaphoneAlgorithm.compute("zq").get must beEqualTo("sk") + MetaphoneAlgorithm.compute("zqz").get must beEqualTo("sks") + + // p + MetaphoneAlgorithm.compute("p").get must beEqualTo("p") + MetaphoneAlgorithm.compute("zp").get must beEqualTo("sp") + MetaphoneAlgorithm.compute("zph").get must beEqualTo("sf") + MetaphoneAlgorithm.compute("zpz").get must beEqualTo("sps") + + // o + MetaphoneAlgorithm.compute("o").get must beEqualTo("o") + MetaphoneAlgorithm.compute("zo").get must beEqualTo("s") + + // n + MetaphoneAlgorithm.compute("n").get must beEqualTo("n") + MetaphoneAlgorithm.compute("zn").get must beEqualTo("sn") + MetaphoneAlgorithm.compute("znz").get must beEqualTo("sns") + + // m + MetaphoneAlgorithm.compute("m").get must beEqualTo("m") + MetaphoneAlgorithm.compute("zm").get must beEqualTo("sm") + MetaphoneAlgorithm.compute("zmz").get must beEqualTo("sms") + + // l + MetaphoneAlgorithm.compute("l").get must beEqualTo("l") + MetaphoneAlgorithm.compute("zl").get must beEqualTo("sl") + MetaphoneAlgorithm.compute("zlz").get must beEqualTo("sls") + + // k + MetaphoneAlgorithm.compute("k").get must beEqualTo("k") + MetaphoneAlgorithm.compute("zk").get must beEqualTo("sk") + MetaphoneAlgorithm.compute("zck").get must beEqualTo("sk") + + // j + MetaphoneAlgorithm.compute("j").get must beEqualTo("j") + MetaphoneAlgorithm.compute("zj").get must beEqualTo("sj") + MetaphoneAlgorithm.compute("zjz").get must beEqualTo("sjs") + + // i + MetaphoneAlgorithm.compute("i").get must beEqualTo("i") + MetaphoneAlgorithm.compute("zi").get must beEqualTo("s") + + // h + MetaphoneAlgorithm.compute("h").get must beEqualTo("h") // php wrongly says nothing + MetaphoneAlgorithm.compute("zh").get must beEqualTo("sh") // php wrongly says s + MetaphoneAlgorithm.compute("zah").get must beEqualTo("s") + MetaphoneAlgorithm.compute("zchh").get must beEqualTo("sx") + MetaphoneAlgorithm.compute("ha").get must beEqualTo("h") + + // g + MetaphoneAlgorithm.compute("g").get must beEqualTo("k") + MetaphoneAlgorithm.compute("zg").get must beEqualTo("sk") + MetaphoneAlgorithm.compute("zgh").get must beEqualTo("skh") // php wrongly says sf + MetaphoneAlgorithm.compute("zghz").get must beEqualTo("shs") // php wrongly says sfs + MetaphoneAlgorithm.compute("zgha").get must beEqualTo("sh") // php wrongly says sf others wrongly say skh + MetaphoneAlgorithm.compute("zgn").get must beEqualTo("sn") + MetaphoneAlgorithm.compute("zgns").get must beEqualTo("skns") + MetaphoneAlgorithm.compute("zgned").get must beEqualTo("snt") // others wrongly says sknt + MetaphoneAlgorithm.compute("zgneds").get must beEqualTo("sknts") // php wrongly says snts + MetaphoneAlgorithm.compute("zgi").get must beEqualTo("sj") + MetaphoneAlgorithm.compute("zgiz").get must beEqualTo("sjs") + MetaphoneAlgorithm.compute("zge").get must beEqualTo("sj") + MetaphoneAlgorithm.compute("zgez").get must beEqualTo("sjs") + MetaphoneAlgorithm.compute("zgy").get must beEqualTo("sj") + MetaphoneAlgorithm.compute("zgyz").get must beEqualTo("sjs") + MetaphoneAlgorithm.compute("zgz").get must beEqualTo("sks") + + // f + MetaphoneAlgorithm.compute("f").get must beEqualTo("f") + MetaphoneAlgorithm.compute("zf").get must beEqualTo("sf") + MetaphoneAlgorithm.compute("zfz").get must beEqualTo("sfs") + + // e + MetaphoneAlgorithm.compute("e").get must beEqualTo("e") + MetaphoneAlgorithm.compute("ze").get must beEqualTo("s") + + // d + MetaphoneAlgorithm.compute("d").get must beEqualTo("t") + MetaphoneAlgorithm.compute("fudge").get must beEqualTo("fjj") // php wrongly says fj + MetaphoneAlgorithm.compute("dodgy").get must beEqualTo("tjj") // php wrongly says tj others wrongly say tjjy + MetaphoneAlgorithm.compute("dodgi").get must beEqualTo("tjj") // php wrongly says tj + MetaphoneAlgorithm.compute("zd").get must beEqualTo("st") + MetaphoneAlgorithm.compute("zdz").get must beEqualTo("sts") + + // c + MetaphoneAlgorithm.compute("c").get must beEqualTo("k") + MetaphoneAlgorithm.compute("zcia").get must beEqualTo("sx") + MetaphoneAlgorithm.compute("zciaz").get must beEqualTo("sxs") + MetaphoneAlgorithm.compute("zch").get must beEqualTo("sx") + MetaphoneAlgorithm.compute("zchz").get must beEqualTo("sxs") + MetaphoneAlgorithm.compute("zci").get must beEqualTo("ss") + MetaphoneAlgorithm.compute("zciz").get must beEqualTo("sss") + MetaphoneAlgorithm.compute("zce").get must beEqualTo("ss") + MetaphoneAlgorithm.compute("zcez").get must beEqualTo("sss") + MetaphoneAlgorithm.compute("zcy").get must beEqualTo("ss") + MetaphoneAlgorithm.compute("zcyz").get must beEqualTo("sss") + MetaphoneAlgorithm.compute("zsci").get must beEqualTo("ss") + MetaphoneAlgorithm.compute("zsciz").get must beEqualTo("sss") + MetaphoneAlgorithm.compute("zsce").get must beEqualTo("ss") + MetaphoneAlgorithm.compute("zscez").get must beEqualTo("sss") + MetaphoneAlgorithm.compute("zscy").get must beEqualTo("ss") + MetaphoneAlgorithm.compute("zscyz").get must beEqualTo("sss") + MetaphoneAlgorithm.compute("zsch").get must beEqualTo("sskh") // php wrongly says ssx + MetaphoneAlgorithm.compute("zc").get must beEqualTo("sk") + MetaphoneAlgorithm.compute("zcz").get must beEqualTo("sks") + + // b + MetaphoneAlgorithm.compute("b").get must beEqualTo("b") + MetaphoneAlgorithm.compute("zb").get must beEqualTo("sb") + MetaphoneAlgorithm.compute("zbz").get must beEqualTo("sbs") + MetaphoneAlgorithm.compute("zmb").get must beEqualTo("sm") + + // a + MetaphoneAlgorithm.compute("a").get must beEqualTo("a") + MetaphoneAlgorithm.compute("za").get must beEqualTo("s") + + // Miscellaneous. + MetaphoneAlgorithm.compute("dumb").get must beEqualTo("tm") + MetaphoneAlgorithm.compute("smith").get must beEqualTo("sm0") + MetaphoneAlgorithm.compute("school").get must beEqualTo("skhl") // php wrongly says sxl + MetaphoneAlgorithm.compute("merci").get must beEqualTo("mrs") + MetaphoneAlgorithm.compute("cool").get must beEqualTo("kl") + MetaphoneAlgorithm.compute("aebersold").get must beEqualTo("ebrslt") + MetaphoneAlgorithm.compute("gnagy").get must beEqualTo("nj") + MetaphoneAlgorithm.compute("knuth").get must beEqualTo("n0") + MetaphoneAlgorithm.compute("pniewski").get must beEqualTo("nsk") + MetaphoneAlgorithm.compute("wright").get must beEqualTo("rht") // php wrongly says rft + MetaphoneAlgorithm.compute("phone").get must beEqualTo("fn") + MetaphoneAlgorithm.compute("aggregate").get must beEqualTo("akrkt") + MetaphoneAlgorithm.compute("accuracy").get must beEqualTo("akkrs") + MetaphoneAlgorithm.compute("encyclopedia").get must beEqualTo("ensklpt") + MetaphoneAlgorithm.compute("honorificabilitudinitatibus").get must beEqualTo("hnrfkblttnttbs") + MetaphoneAlgorithm.compute("antidisestablishmentarianism").get must beEqualTo("anttsstblxmntrnsm") } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala index 05401b0..aae4cbc 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala @@ -1,39 +1,28 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - MetaphoneMetric.compare("", "").isDefined should be (false) - MetaphoneMetric.compare("abc", "").isDefined should be (false) - MetaphoneMetric.compare("", "xyz").isDefined should be (false) - } +object MetaphoneMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "MetaphoneMetric compare()" should { + "return None with empty arguments" in { + MetaphoneMetric.compare("", "").isDefined must beFalse + MetaphoneMetric.compare("abc", "").isDefined must beFalse + MetaphoneMetric.compare("", "xyz").isDefined must beFalse } - "non-phonetic arguments" should returns { + "return None with non-phonetic arguments" in { "None" in { - MetaphoneMetric.compare("123", "123").isDefined should be (false) - MetaphoneMetric.compare("123", "").isDefined should be (false) - MetaphoneMetric.compare("", "123").isDefined should be (false) + MetaphoneMetric.compare("123", "123").isDefined must beFalse + MetaphoneMetric.compare("123", "").isDefined must beFalse + MetaphoneMetric.compare("", "123").isDefined must beFalse } } - "phonetically similar arguments" should returns { - "Boolean indicating true" in { - MetaphoneMetric.compare("dumb", "dum").get should be (true) - MetaphoneMetric.compare("smith", "smeth").get should be (true) - MetaphoneMetric.compare("merci", "mercy").get should be (true) - } + "return true with phonetically similar arguments" in { + MetaphoneMetric.compare("dumb", "dum").get must beTrue + MetaphoneMetric.compare("smith", "smeth").get must beTrue + MetaphoneMetric.compare("merci", "mercy").get must beTrue } - "phonetically dissimilar arguments" should returns { - "Boolean indicating false" in { - MetaphoneMetric.compare("dumb", "gum").get should be (false) - MetaphoneMetric.compare("smith", "kiss").get should be (false) - MetaphoneMetric.compare("merci", "burpy").get should be (false) - } + "return false with phonetically dissimilar arguments" in { + MetaphoneMetric.compare("dumb", "gum").get must beFalse + MetaphoneMetric.compare("smith", "kiss").get must beFalse + MetaphoneMetric.compare("merci", "burpy").get must beFalse } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala index db8e073..7cb3708 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala @@ -1,189 +1,178 @@ package com.rockymadden.stringmetric.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 { - "compute method" when passed { - "empty argument" should returns { - "None" in { - NysiisAlgorithm.compute("").isDefined should be (false) - } +object NysiisAlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "NysiisAlgorithm compute()" should { + "return None with empty argument" in { + NysiisAlgorithm.compute("").isDefined must beFalse } - "non-phonetic argument" should returns { - "None" in { - NysiisAlgorithm.compute("123").isDefined should be (false) - } + "return None with non-phonetic argument" in { + NysiisAlgorithm.compute("123").isDefined must beFalse } - "phonetic argument" should returns { - "Some" in { - // a - NysiisAlgorithm.compute("a").get should equal ("a") - NysiisAlgorithm.compute("aa").get should equal ("a") + "return Some with phonetic argument" in { + // a + NysiisAlgorithm.compute("a").get must beEqualTo("a") + NysiisAlgorithm.compute("aa").get must beEqualTo("a") - // b - NysiisAlgorithm.compute("b").get should equal ("b") - NysiisAlgorithm.compute("bb").get should equal ("bb") - - // c - NysiisAlgorithm.compute("c").get should equal ("c") - NysiisAlgorithm.compute("cc").get should equal ("cc") - - // d - NysiisAlgorithm.compute("d").get should equal ("d") - NysiisAlgorithm.compute("dd").get should equal ("dd") - - // e - NysiisAlgorithm.compute("e").get should equal ("e") - NysiisAlgorithm.compute("ee").get should equal ("y") - - // f - NysiisAlgorithm.compute("f").get should equal ("f") - NysiisAlgorithm.compute("ff").get should equal ("ff") - - // g - NysiisAlgorithm.compute("g").get should equal ("g") - NysiisAlgorithm.compute("gg").get should equal ("gg") - - // h - NysiisAlgorithm.compute("h").get should equal ("h") - NysiisAlgorithm.compute("hh").get should equal ("hh") - - // i - NysiisAlgorithm.compute("i").get should equal ("i") - NysiisAlgorithm.compute("ii").get should equal ("i") - - // j - NysiisAlgorithm.compute("j").get should equal ("j") - NysiisAlgorithm.compute("jj").get should equal ("jj") - - // k - NysiisAlgorithm.compute("k").get should equal ("c") - NysiisAlgorithm.compute("kk").get should equal ("cc") - - // l - NysiisAlgorithm.compute("l").get should equal ("l") - NysiisAlgorithm.compute("ll").get should equal ("ll") - - // m - NysiisAlgorithm.compute("m").get should equal ("m") - NysiisAlgorithm.compute("mm").get should equal ("mn") - - // n - NysiisAlgorithm.compute("n").get should equal ("n") - NysiisAlgorithm.compute("nn").get should equal ("nn") - - // o - NysiisAlgorithm.compute("o").get should equal ("o") - NysiisAlgorithm.compute("oo").get should equal ("o") - - // p - NysiisAlgorithm.compute("p").get should equal ("p") - NysiisAlgorithm.compute("pp").get should equal ("pp") - - // q - NysiisAlgorithm.compute("q").get should equal ("q") - NysiisAlgorithm.compute("qq").get should equal ("qg") - - // r - NysiisAlgorithm.compute("r").get should equal ("r") - NysiisAlgorithm.compute("rr").get should equal ("rr") - - // s - NysiisAlgorithm.compute("s").get should equal ("s") - NysiisAlgorithm.compute("ss").get should equal ("s") - - // t - NysiisAlgorithm.compute("t").get should equal ("t") - NysiisAlgorithm.compute("tt").get should equal ("tt") - - // u - NysiisAlgorithm.compute("u").get should equal ("u") - NysiisAlgorithm.compute("uu").get should equal ("u") - - // v - NysiisAlgorithm.compute("v").get should equal ("v") - NysiisAlgorithm.compute("vv").get should equal ("vv") - - // w - NysiisAlgorithm.compute("w").get should equal ("w") - NysiisAlgorithm.compute("ww").get should equal ("ww") - - // x - NysiisAlgorithm.compute("x").get should equal ("x") - NysiisAlgorithm.compute("xx").get should equal ("xx") - - // y - NysiisAlgorithm.compute("y").get should equal ("y") - NysiisAlgorithm.compute("yy").get should equal ("yy") - - // z - NysiisAlgorithm.compute("z").get should equal ("z") - NysiisAlgorithm.compute("zz").get should equal ("z") - - // Head cases. - NysiisAlgorithm.compute("mac").get should equal ("mc") - NysiisAlgorithm.compute("kn").get should equal ("nn") - NysiisAlgorithm.compute("k").get should equal ("c") - NysiisAlgorithm.compute("ph").get should equal ("ff") - NysiisAlgorithm.compute("pf").get should equal ("ff") - NysiisAlgorithm.compute("sch").get should equal ("s") // dropby wrongly says ss - - // Last cases. - NysiisAlgorithm.compute("ee").get should equal ("y") - NysiisAlgorithm.compute("ie").get should equal ("y") - NysiisAlgorithm.compute("dt").get should equal ("d") - NysiisAlgorithm.compute("rt").get should equal ("d") - NysiisAlgorithm.compute("rd").get should equal ("d") - NysiisAlgorithm.compute("nt").get should equal ("d") - NysiisAlgorithm.compute("nd").get should equal ("d") - - // Core cases. - NysiisAlgorithm.compute("eev").get should equal ("eaf") - NysiisAlgorithm.compute("zev").get should equal ("zaf") - NysiisAlgorithm.compute("kkn").get should equal ("cn") - NysiisAlgorithm.compute("sschn").get should equal ("ssn") - NysiisAlgorithm.compute("pph").get should equal ("pf") - - // Miscellaneous. - NysiisAlgorithm.compute("macdonald").get should equal ("mcdanald") - NysiisAlgorithm.compute("phone").get should equal ("ffan") - NysiisAlgorithm.compute("aggregate").get should equal ("agragat") - NysiisAlgorithm.compute("accuracy").get should equal ("acaracy") - NysiisAlgorithm.compute("encyclopedia").get should equal ("encyclapad") - NysiisAlgorithm.compute("honorificabilitudinitatibus").get should equal ("hanarafacabalatadanatatab") - NysiisAlgorithm.compute("antidisestablishmentarianism").get should equal ("antadasastablasnantaranasn") - - // Dropby. - NysiisAlgorithm.compute("macintosh").get should equal ("mcant") - NysiisAlgorithm.compute("knuth").get should equal ("nnat") - NysiisAlgorithm.compute("koehn").get should equal ("can") // dropby wrongly says c - NysiisAlgorithm.compute("phillipson").get should equal ("ffalapsan") - NysiisAlgorithm.compute("pfeister").get should equal ("ffastar") - NysiisAlgorithm.compute("schoenhoeft").get should equal ("ssanaft") - NysiisAlgorithm.compute("mckee").get should equal ("mcy") - NysiisAlgorithm.compute("heitschmedt").get should equal ("hatsnad") - NysiisAlgorithm.compute("bart").get should equal ("bad") - NysiisAlgorithm.compute("hurd").get should equal ("had") - NysiisAlgorithm.compute("hunt").get should equal ("had") - NysiisAlgorithm.compute("westerlund").get should equal ("wastarlad") - NysiisAlgorithm.compute("casstevens").get should equal ("castafan") - NysiisAlgorithm.compute("vasquez").get should equal ("vasg") - NysiisAlgorithm.compute("frazier").get should equal ("frasar") - NysiisAlgorithm.compute("bowman").get should equal ("banan") - NysiisAlgorithm.compute("mcknight").get should equal ("mcnagt") - NysiisAlgorithm.compute("rickert").get should equal ("racad") - NysiisAlgorithm.compute("deutsch").get should equal ("dat") // dropby wrongly says dats - NysiisAlgorithm.compute("westphal").get should equal ("wastfal") - NysiisAlgorithm.compute("shriver").get should equal ("shravar") - NysiisAlgorithm.compute("kuhl").get should equal ("cal") // dropby wrongly says c - NysiisAlgorithm.compute("rawson").get should equal ("rasan") - NysiisAlgorithm.compute("jiles").get should equal ("jal") - NysiisAlgorithm.compute("carraway").get should equal ("caray") - NysiisAlgorithm.compute("yamada").get should equal ("yanad") - } + // b + NysiisAlgorithm.compute("b").get must beEqualTo("b") + NysiisAlgorithm.compute("bb").get must beEqualTo("bb") + + // c + NysiisAlgorithm.compute("c").get must beEqualTo("c") + NysiisAlgorithm.compute("cc").get must beEqualTo("cc") + + // d + NysiisAlgorithm.compute("d").get must beEqualTo("d") + NysiisAlgorithm.compute("dd").get must beEqualTo("dd") + + // e + NysiisAlgorithm.compute("e").get must beEqualTo("e") + NysiisAlgorithm.compute("ee").get must beEqualTo("y") + + // f + NysiisAlgorithm.compute("f").get must beEqualTo("f") + NysiisAlgorithm.compute("ff").get must beEqualTo("ff") + + // g + NysiisAlgorithm.compute("g").get must beEqualTo("g") + NysiisAlgorithm.compute("gg").get must beEqualTo("gg") + + // h + NysiisAlgorithm.compute("h").get must beEqualTo("h") + NysiisAlgorithm.compute("hh").get must beEqualTo("hh") + + // i + NysiisAlgorithm.compute("i").get must beEqualTo("i") + NysiisAlgorithm.compute("ii").get must beEqualTo("i") + + // j + NysiisAlgorithm.compute("j").get must beEqualTo("j") + NysiisAlgorithm.compute("jj").get must beEqualTo("jj") + + // k + NysiisAlgorithm.compute("k").get must beEqualTo("c") + NysiisAlgorithm.compute("kk").get must beEqualTo("cc") + + // l + NysiisAlgorithm.compute("l").get must beEqualTo("l") + NysiisAlgorithm.compute("ll").get must beEqualTo("ll") + + // m + NysiisAlgorithm.compute("m").get must beEqualTo("m") + NysiisAlgorithm.compute("mm").get must beEqualTo("mn") + + // n + NysiisAlgorithm.compute("n").get must beEqualTo("n") + NysiisAlgorithm.compute("nn").get must beEqualTo("nn") + + // o + NysiisAlgorithm.compute("o").get must beEqualTo("o") + NysiisAlgorithm.compute("oo").get must beEqualTo("o") + + // p + NysiisAlgorithm.compute("p").get must beEqualTo("p") + NysiisAlgorithm.compute("pp").get must beEqualTo("pp") + + // q + NysiisAlgorithm.compute("q").get must beEqualTo("q") + NysiisAlgorithm.compute("qq").get must beEqualTo("qg") + + // r + NysiisAlgorithm.compute("r").get must beEqualTo("r") + NysiisAlgorithm.compute("rr").get must beEqualTo("rr") + + // s + NysiisAlgorithm.compute("s").get must beEqualTo("s") + NysiisAlgorithm.compute("ss").get must beEqualTo("s") + + // t + NysiisAlgorithm.compute("t").get must beEqualTo("t") + NysiisAlgorithm.compute("tt").get must beEqualTo("tt") + + // u + NysiisAlgorithm.compute("u").get must beEqualTo("u") + NysiisAlgorithm.compute("uu").get must beEqualTo("u") + + // v + NysiisAlgorithm.compute("v").get must beEqualTo("v") + NysiisAlgorithm.compute("vv").get must beEqualTo("vv") + + // w + NysiisAlgorithm.compute("w").get must beEqualTo("w") + NysiisAlgorithm.compute("ww").get must beEqualTo("ww") + + // x + NysiisAlgorithm.compute("x").get must beEqualTo("x") + NysiisAlgorithm.compute("xx").get must beEqualTo("xx") + + // y + NysiisAlgorithm.compute("y").get must beEqualTo("y") + NysiisAlgorithm.compute("yy").get must beEqualTo("yy") + + // z + NysiisAlgorithm.compute("z").get must beEqualTo("z") + NysiisAlgorithm.compute("zz").get must beEqualTo("z") + + // Head cases. + NysiisAlgorithm.compute("mac").get must beEqualTo("mc") + NysiisAlgorithm.compute("kn").get must beEqualTo("nn") + NysiisAlgorithm.compute("k").get must beEqualTo("c") + NysiisAlgorithm.compute("ph").get must beEqualTo("ff") + NysiisAlgorithm.compute("pf").get must beEqualTo("ff") + NysiisAlgorithm.compute("sch").get must beEqualTo("s") // dropby wrongly says ss + + // Last cases. + NysiisAlgorithm.compute("ee").get must beEqualTo("y") + NysiisAlgorithm.compute("ie").get must beEqualTo("y") + NysiisAlgorithm.compute("dt").get must beEqualTo("d") + NysiisAlgorithm.compute("rt").get must beEqualTo("d") + NysiisAlgorithm.compute("rd").get must beEqualTo("d") + NysiisAlgorithm.compute("nt").get must beEqualTo("d") + NysiisAlgorithm.compute("nd").get must beEqualTo("d") + + // Core cases. + NysiisAlgorithm.compute("eev").get must beEqualTo("eaf") + NysiisAlgorithm.compute("zev").get must beEqualTo("zaf") + NysiisAlgorithm.compute("kkn").get must beEqualTo("cn") + NysiisAlgorithm.compute("sschn").get must beEqualTo("ssn") + NysiisAlgorithm.compute("pph").get must beEqualTo("pf") + + // Miscellaneous. + NysiisAlgorithm.compute("macdonald").get must beEqualTo("mcdanald") + NysiisAlgorithm.compute("phone").get must beEqualTo("ffan") + NysiisAlgorithm.compute("aggregate").get must beEqualTo("agragat") + NysiisAlgorithm.compute("accuracy").get must beEqualTo("acaracy") + NysiisAlgorithm.compute("encyclopedia").get must beEqualTo("encyclapad") + NysiisAlgorithm.compute("honorificabilitudinitatibus").get must beEqualTo("hanarafacabalatadanatatab") + NysiisAlgorithm.compute("antidisestablishmentarianism").get must beEqualTo("antadasastablasnantaranasn") + + // Dropby. + NysiisAlgorithm.compute("macintosh").get must beEqualTo("mcant") + NysiisAlgorithm.compute("knuth").get must beEqualTo("nnat") + NysiisAlgorithm.compute("koehn").get must beEqualTo("can") // dropby wrongly says c + NysiisAlgorithm.compute("phillipson").get must beEqualTo("ffalapsan") + NysiisAlgorithm.compute("pfeister").get must beEqualTo("ffastar") + NysiisAlgorithm.compute("schoenhoeft").get must beEqualTo("ssanaft") + NysiisAlgorithm.compute("mckee").get must beEqualTo("mcy") + NysiisAlgorithm.compute("heitschmedt").get must beEqualTo("hatsnad") + NysiisAlgorithm.compute("bart").get must beEqualTo("bad") + NysiisAlgorithm.compute("hurd").get must beEqualTo("had") + NysiisAlgorithm.compute("hunt").get must beEqualTo("had") + NysiisAlgorithm.compute("westerlund").get must beEqualTo("wastarlad") + NysiisAlgorithm.compute("casstevens").get must beEqualTo("castafan") + NysiisAlgorithm.compute("vasquez").get must beEqualTo("vasg") + NysiisAlgorithm.compute("frazier").get must beEqualTo("frasar") + NysiisAlgorithm.compute("bowman").get must beEqualTo("banan") + NysiisAlgorithm.compute("mcknight").get must beEqualTo("mcnagt") + NysiisAlgorithm.compute("rickert").get must beEqualTo("racad") + NysiisAlgorithm.compute("deutsch").get must beEqualTo("dat") // dropby wrongly says dats + NysiisAlgorithm.compute("westphal").get must beEqualTo("wastfal") + NysiisAlgorithm.compute("shriver").get must beEqualTo("shravar") + NysiisAlgorithm.compute("kuhl").get must beEqualTo("cal") // dropby wrongly says c + NysiisAlgorithm.compute("rawson").get must beEqualTo("rasan") + NysiisAlgorithm.compute("jiles").get must beEqualTo("jal") + NysiisAlgorithm.compute("carraway").get must beEqualTo("caray") + NysiisAlgorithm.compute("yamada").get must beEqualTo("yanad") } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala index 7e52101..d65165b 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala @@ -1,37 +1,22 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - NysiisMetric.compare("", "").isDefined should be (false) - NysiisMetric.compare("abc", "").isDefined should be (false) - NysiisMetric.compare("", "xyz").isDefined should be (false) - } - } - "non-phonetic arguments" should returns { - "None" in { - NysiisMetric.compare("123", "123").isDefined should be (false) - NysiisMetric.compare("123", "").isDefined should be (false) - NysiisMetric.compare("", "123").isDefined should be (false) - } - } - "phonetically similar arguments" should returns { - "Boolean indicating true" in { - NysiisMetric.compare("ham", "hum").get should be (true) - } - } - "phonetically dissimilar arguments" should returns { - "Boolean indicating false" in { - NysiisMetric.compare("dumb", "gum").get should be (false) - } - } +object NysiisMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "NysiisMetric compare()" should { + "return None with empty arguments" in { + NysiisMetric.compare("", "").isDefined must beFalse + NysiisMetric.compare("abc", "").isDefined must beFalse + NysiisMetric.compare("", "xyz").isDefined must beFalse + } + "return None with non-phonetic arguments" in { + NysiisMetric.compare("123", "123").isDefined must beFalse + NysiisMetric.compare("123", "").isDefined must beFalse + NysiisMetric.compare("", "123").isDefined must beFalse + } + "return true with phonetically similar arguments" in { + NysiisMetric.compare("ham", "hum").get must beTrue + } + "return false with phonetically dissimilar arguments" in { + NysiisMetric.compare("dumb", "gum").get must beFalse } } } diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala index 9602f16..5b0f46d 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala @@ -1,206 +1,195 @@ package com.rockymadden.stringmetric.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 { - "compute method" when passed { - "empty argument" should returns { - "None" in { - RefinedNysiisAlgorithm.compute("").isDefined should be (false) - } +object RefinedNysiisAlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "RefinedNysiisAlgorithm compute()" should { + "return None with empty argument" in { + RefinedNysiisAlgorithm.compute("").isDefined must beFalse } - "non-phonetic argument" should returns { - "None" in { - RefinedNysiisAlgorithm.compute("123").isDefined should be (false) - } + "return None with non-phonetic argument" in { + RefinedNysiisAlgorithm.compute("123").isDefined must beFalse } - "phonetic argument" should returns { - "Some" in { - // a - RefinedNysiisAlgorithm.compute("a").get should equal ("a") - RefinedNysiisAlgorithm.compute("aa").get should equal ("a") - - // b - RefinedNysiisAlgorithm.compute("b").get should equal ("b") - RefinedNysiisAlgorithm.compute("bb").get should equal ("b") - - // c - RefinedNysiisAlgorithm.compute("c").get should equal ("c") - RefinedNysiisAlgorithm.compute("cc").get should equal ("c") - - // d - RefinedNysiisAlgorithm.compute("d").get should equal ("d") - RefinedNysiisAlgorithm.compute("dd").get should equal ("d") - - // e - RefinedNysiisAlgorithm.compute("e").get should equal ("e") - RefinedNysiisAlgorithm.compute("ee").get should equal ("y") - - // f - RefinedNysiisAlgorithm.compute("f").get should equal ("f") - RefinedNysiisAlgorithm.compute("ff").get should equal ("f") - - // g - RefinedNysiisAlgorithm.compute("g").get should equal ("g") - RefinedNysiisAlgorithm.compute("gg").get should equal ("g") - - // h - RefinedNysiisAlgorithm.compute("h").get should equal ("h") - RefinedNysiisAlgorithm.compute("hh").get should equal ("h") - - // i - RefinedNysiisAlgorithm.compute("i").get should equal ("i") - RefinedNysiisAlgorithm.compute("ii").get should equal ("i") - - // j - RefinedNysiisAlgorithm.compute("j").get should equal ("j") - RefinedNysiisAlgorithm.compute("jj").get should equal ("j") - - // k - RefinedNysiisAlgorithm.compute("k").get should equal ("c") - RefinedNysiisAlgorithm.compute("kk").get should equal ("c") - - // l - RefinedNysiisAlgorithm.compute("l").get should equal ("l") - RefinedNysiisAlgorithm.compute("ll").get should equal ("l") - - // m - RefinedNysiisAlgorithm.compute("m").get should equal ("m") - RefinedNysiisAlgorithm.compute("mm").get should equal ("mn") - - // n - RefinedNysiisAlgorithm.compute("n").get should equal ("n") - RefinedNysiisAlgorithm.compute("nn").get should equal ("n") - - // o - RefinedNysiisAlgorithm.compute("o").get should equal ("o") - RefinedNysiisAlgorithm.compute("oo").get should equal ("o") - - // p - RefinedNysiisAlgorithm.compute("p").get should equal ("p") - RefinedNysiisAlgorithm.compute("pp").get should equal ("p") - - // q - RefinedNysiisAlgorithm.compute("q").get should equal ("q") - RefinedNysiisAlgorithm.compute("qq").get should equal ("qg") - - // r - RefinedNysiisAlgorithm.compute("r").get should equal ("r") - RefinedNysiisAlgorithm.compute("rr").get should equal ("r") - - // s - RefinedNysiisAlgorithm.compute("s").get should equal ("s") - RefinedNysiisAlgorithm.compute("ss").get should equal ("s") - - // t - RefinedNysiisAlgorithm.compute("t").get should equal ("t") - RefinedNysiisAlgorithm.compute("tt").get should equal ("t") - - // u - RefinedNysiisAlgorithm.compute("u").get should equal ("u") - RefinedNysiisAlgorithm.compute("uu").get should equal ("u") - - // v - RefinedNysiisAlgorithm.compute("v").get should equal ("v") - RefinedNysiisAlgorithm.compute("vv").get should equal ("v") - - // w - RefinedNysiisAlgorithm.compute("w").get should equal ("w") - RefinedNysiisAlgorithm.compute("ww").get should equal ("w") - - // x - RefinedNysiisAlgorithm.compute("x").get should equal ("x") - RefinedNysiisAlgorithm.compute("xx").get should equal ("x") - - // y - RefinedNysiisAlgorithm.compute("y").get should equal ("y") - RefinedNysiisAlgorithm.compute("yy").get should equal ("y") - RefinedNysiisAlgorithm.compute("ybyb").get should equal ("ybab") - - // z - RefinedNysiisAlgorithm.compute("z").get should equal ("z") - RefinedNysiisAlgorithm.compute("zz").get should equal ("z") - - // Head cases. - RefinedNysiisAlgorithm.compute("mac").get should equal ("mc") - RefinedNysiisAlgorithm.compute("pf").get should equal ("f") - - // Last cases. - RefinedNysiisAlgorithm.compute("ix").get should equal ("ic") - RefinedNysiisAlgorithm.compute("ex").get should equal ("ec") - RefinedNysiisAlgorithm.compute("ye").get should equal ("y") - RefinedNysiisAlgorithm.compute("ee").get should equal ("y") - RefinedNysiisAlgorithm.compute("ie").get should equal ("y") - RefinedNysiisAlgorithm.compute("dt").get should equal ("d") - RefinedNysiisAlgorithm.compute("rt").get should equal ("d") - RefinedNysiisAlgorithm.compute("rd").get should equal ("d") - RefinedNysiisAlgorithm.compute("nt").get should equal ("d") - RefinedNysiisAlgorithm.compute("nd").get should equal ("d") - - // Core cases. - RefinedNysiisAlgorithm.compute("bevb").get should equal ("bafb") - RefinedNysiisAlgorithm.compute("bghtb").get should equal ("bgtb") - RefinedNysiisAlgorithm.compute("bdgb").get should equal ("bgb") - RefinedNysiisAlgorithm.compute("bphb").get should equal ("bfb") - RefinedNysiisAlgorithm.compute("bknb").get should equal ("bnb") - RefinedNysiisAlgorithm.compute("bshb").get should equal ("bsb") - RefinedNysiisAlgorithm.compute("bschb").get should equal ("bsb") - RefinedNysiisAlgorithm.compute("bywb").get should equal ("bab") - RefinedNysiisAlgorithm.compute("byw").get should equal ("by") - RefinedNysiisAlgorithm.compute("ywb").get should equal ("yb") - RefinedNysiisAlgorithm.compute("bwrb").get should equal ("brb") - - // Transcode cases. - RefinedNysiisAlgorithm.compute("bay").get should equal ("by") - - // Miscellaneous. - RefinedNysiisAlgorithm.compute("macdonald").get should equal ("mcdanald") - RefinedNysiisAlgorithm.compute("phone").get should equal ("fan") - RefinedNysiisAlgorithm.compute("aggregate").get should equal ("agragat") - RefinedNysiisAlgorithm.compute("accuracy").get should equal ("acaracy") - RefinedNysiisAlgorithm.compute("encyclopedia").get should equal ("encaclapad") - RefinedNysiisAlgorithm.compute("honorificabilitudinitatibus").get should equal ("hanarafacabalatadanatatab") - RefinedNysiisAlgorithm.compute("antidisestablishmentarianism").get should equal ("antadasastablasnantaranasn") - - // Dropby. - RefinedNysiisAlgorithm.compute("edwards").get should equal ("edwad") - RefinedNysiisAlgorithm.compute("parez").get should equal ("par") - RefinedNysiisAlgorithm.compute("macintosh").get should equal ("mcantas") - RefinedNysiisAlgorithm.compute("phillipson").get should equal ("falapsan") - RefinedNysiisAlgorithm.compute("haddix").get should equal ("hadac") - RefinedNysiisAlgorithm.compute("essex").get should equal ("esac") - RefinedNysiisAlgorithm.compute("moye").get should equal ("my") - RefinedNysiisAlgorithm.compute("mckee").get should equal ("mcy") - RefinedNysiisAlgorithm.compute("mackie").get should equal ("mcy") - RefinedNysiisAlgorithm.compute("heitschmidt").get should equal ("hatsnad") - RefinedNysiisAlgorithm.compute("bart").get should equal ("bad") - RefinedNysiisAlgorithm.compute("hurd").get should equal ("had") - RefinedNysiisAlgorithm.compute("hunt").get should equal ("had") - RefinedNysiisAlgorithm.compute("westerlund").get should equal ("wastarlad") - RefinedNysiisAlgorithm.compute("evers").get should equal ("evar") - RefinedNysiisAlgorithm.compute("devito").get should equal ("dafat") - RefinedNysiisAlgorithm.compute("rawson").get should equal ("rasan") - RefinedNysiisAlgorithm.compute("shoulders").get should equal ("saldar") - RefinedNysiisAlgorithm.compute("leighton").get should equal ("lagtan") - RefinedNysiisAlgorithm.compute("wooldridge").get should equal ("waldrag") - RefinedNysiisAlgorithm.compute("oliphant").get should equal ("olafad") - RefinedNysiisAlgorithm.compute("hatchett").get should equal ("hatcat") - RefinedNysiisAlgorithm.compute("mcknight").get should equal ("mcnagt") - RefinedNysiisAlgorithm.compute("rickert").get should equal ("racad") - RefinedNysiisAlgorithm.compute("bowman").get should equal ("banan") - RefinedNysiisAlgorithm.compute("vasquez").get should equal ("vasg") - RefinedNysiisAlgorithm.compute("bashaw").get should equal ("bas") - RefinedNysiisAlgorithm.compute("schoenhoeft").get should equal ("sanaft") // dropby wrongly says scanaft - RefinedNysiisAlgorithm.compute("heywood").get should equal ("had") - RefinedNysiisAlgorithm.compute("hayman").get should equal ("hanan") - RefinedNysiisAlgorithm.compute("seawright").get should equal ("saragt") - RefinedNysiisAlgorithm.compute("kratzer").get should equal ("cratsar") - RefinedNysiisAlgorithm.compute("canaday").get should equal ("canady") - RefinedNysiisAlgorithm.compute("crepeau").get should equal ("crap") - } + "return Some with phonetic argument" in { + // a + RefinedNysiisAlgorithm.compute("a").get must beEqualTo("a") + RefinedNysiisAlgorithm.compute("aa").get must beEqualTo("a") + + // b + RefinedNysiisAlgorithm.compute("b").get must beEqualTo("b") + RefinedNysiisAlgorithm.compute("bb").get must beEqualTo("b") + + // c + RefinedNysiisAlgorithm.compute("c").get must beEqualTo("c") + RefinedNysiisAlgorithm.compute("cc").get must beEqualTo("c") + + // d + RefinedNysiisAlgorithm.compute("d").get must beEqualTo("d") + RefinedNysiisAlgorithm.compute("dd").get must beEqualTo("d") + + // e + RefinedNysiisAlgorithm.compute("e").get must beEqualTo("e") + RefinedNysiisAlgorithm.compute("ee").get must beEqualTo("y") + + // f + RefinedNysiisAlgorithm.compute("f").get must beEqualTo("f") + RefinedNysiisAlgorithm.compute("ff").get must beEqualTo("f") + + // g + RefinedNysiisAlgorithm.compute("g").get must beEqualTo("g") + RefinedNysiisAlgorithm.compute("gg").get must beEqualTo("g") + + // h + RefinedNysiisAlgorithm.compute("h").get must beEqualTo("h") + RefinedNysiisAlgorithm.compute("hh").get must beEqualTo("h") + + // i + RefinedNysiisAlgorithm.compute("i").get must beEqualTo("i") + RefinedNysiisAlgorithm.compute("ii").get must beEqualTo("i") + + // j + RefinedNysiisAlgorithm.compute("j").get must beEqualTo("j") + RefinedNysiisAlgorithm.compute("jj").get must beEqualTo("j") + + // k + RefinedNysiisAlgorithm.compute("k").get must beEqualTo("c") + RefinedNysiisAlgorithm.compute("kk").get must beEqualTo("c") + + // l + RefinedNysiisAlgorithm.compute("l").get must beEqualTo("l") + RefinedNysiisAlgorithm.compute("ll").get must beEqualTo("l") + + // m + RefinedNysiisAlgorithm.compute("m").get must beEqualTo("m") + RefinedNysiisAlgorithm.compute("mm").get must beEqualTo("mn") + + // n + RefinedNysiisAlgorithm.compute("n").get must beEqualTo("n") + RefinedNysiisAlgorithm.compute("nn").get must beEqualTo("n") + + // o + RefinedNysiisAlgorithm.compute("o").get must beEqualTo("o") + RefinedNysiisAlgorithm.compute("oo").get must beEqualTo("o") + + // p + RefinedNysiisAlgorithm.compute("p").get must beEqualTo("p") + RefinedNysiisAlgorithm.compute("pp").get must beEqualTo("p") + + // q + RefinedNysiisAlgorithm.compute("q").get must beEqualTo("q") + RefinedNysiisAlgorithm.compute("qq").get must beEqualTo("qg") + + // r + RefinedNysiisAlgorithm.compute("r").get must beEqualTo("r") + RefinedNysiisAlgorithm.compute("rr").get must beEqualTo("r") + + // s + RefinedNysiisAlgorithm.compute("s").get must beEqualTo("s") + RefinedNysiisAlgorithm.compute("ss").get must beEqualTo("s") + + // t + RefinedNysiisAlgorithm.compute("t").get must beEqualTo("t") + RefinedNysiisAlgorithm.compute("tt").get must beEqualTo("t") + + // u + RefinedNysiisAlgorithm.compute("u").get must beEqualTo("u") + RefinedNysiisAlgorithm.compute("uu").get must beEqualTo("u") + + // v + RefinedNysiisAlgorithm.compute("v").get must beEqualTo("v") + RefinedNysiisAlgorithm.compute("vv").get must beEqualTo("v") + + // w + RefinedNysiisAlgorithm.compute("w").get must beEqualTo("w") + RefinedNysiisAlgorithm.compute("ww").get must beEqualTo("w") + + // x + RefinedNysiisAlgorithm.compute("x").get must beEqualTo("x") + RefinedNysiisAlgorithm.compute("xx").get must beEqualTo("x") + + // y + RefinedNysiisAlgorithm.compute("y").get must beEqualTo("y") + RefinedNysiisAlgorithm.compute("yy").get must beEqualTo("y") + RefinedNysiisAlgorithm.compute("ybyb").get must beEqualTo("ybab") + + // z + RefinedNysiisAlgorithm.compute("z").get must beEqualTo("z") + RefinedNysiisAlgorithm.compute("zz").get must beEqualTo("z") + + // Head cases. + RefinedNysiisAlgorithm.compute("mac").get must beEqualTo("mc") + RefinedNysiisAlgorithm.compute("pf").get must beEqualTo("f") + + // Last cases. + RefinedNysiisAlgorithm.compute("ix").get must beEqualTo("ic") + RefinedNysiisAlgorithm.compute("ex").get must beEqualTo("ec") + RefinedNysiisAlgorithm.compute("ye").get must beEqualTo("y") + RefinedNysiisAlgorithm.compute("ee").get must beEqualTo("y") + RefinedNysiisAlgorithm.compute("ie").get must beEqualTo("y") + RefinedNysiisAlgorithm.compute("dt").get must beEqualTo("d") + RefinedNysiisAlgorithm.compute("rt").get must beEqualTo("d") + RefinedNysiisAlgorithm.compute("rd").get must beEqualTo("d") + RefinedNysiisAlgorithm.compute("nt").get must beEqualTo("d") + RefinedNysiisAlgorithm.compute("nd").get must beEqualTo("d") + + // Core cases. + RefinedNysiisAlgorithm.compute("bevb").get must beEqualTo("bafb") + RefinedNysiisAlgorithm.compute("bghtb").get must beEqualTo("bgtb") + RefinedNysiisAlgorithm.compute("bdgb").get must beEqualTo("bgb") + RefinedNysiisAlgorithm.compute("bphb").get must beEqualTo("bfb") + RefinedNysiisAlgorithm.compute("bknb").get must beEqualTo("bnb") + RefinedNysiisAlgorithm.compute("bshb").get must beEqualTo("bsb") + RefinedNysiisAlgorithm.compute("bschb").get must beEqualTo("bsb") + RefinedNysiisAlgorithm.compute("bywb").get must beEqualTo("bab") + RefinedNysiisAlgorithm.compute("byw").get must beEqualTo("by") + RefinedNysiisAlgorithm.compute("ywb").get must beEqualTo("yb") + RefinedNysiisAlgorithm.compute("bwrb").get must beEqualTo("brb") + + // Transcode cases. + RefinedNysiisAlgorithm.compute("bay").get must beEqualTo("by") + + // Miscellaneous. + RefinedNysiisAlgorithm.compute("macdonald").get must beEqualTo("mcdanald") + RefinedNysiisAlgorithm.compute("phone").get must beEqualTo("fan") + RefinedNysiisAlgorithm.compute("aggregate").get must beEqualTo("agragat") + RefinedNysiisAlgorithm.compute("accuracy").get must beEqualTo("acaracy") + RefinedNysiisAlgorithm.compute("encyclopedia").get must beEqualTo("encaclapad") + RefinedNysiisAlgorithm.compute("honorificabilitudinitatibus").get must beEqualTo("hanarafacabalatadanatatab") + RefinedNysiisAlgorithm.compute("antidisestablishmentarianism").get must beEqualTo("antadasastablasnantaranasn") + + // Dropby. + RefinedNysiisAlgorithm.compute("edwards").get must beEqualTo("edwad") + RefinedNysiisAlgorithm.compute("parez").get must beEqualTo("par") + RefinedNysiisAlgorithm.compute("macintosh").get must beEqualTo("mcantas") + RefinedNysiisAlgorithm.compute("phillipson").get must beEqualTo("falapsan") + RefinedNysiisAlgorithm.compute("haddix").get must beEqualTo("hadac") + RefinedNysiisAlgorithm.compute("essex").get must beEqualTo("esac") + RefinedNysiisAlgorithm.compute("moye").get must beEqualTo("my") + RefinedNysiisAlgorithm.compute("mckee").get must beEqualTo("mcy") + RefinedNysiisAlgorithm.compute("mackie").get must beEqualTo("mcy") + RefinedNysiisAlgorithm.compute("heitschmidt").get must beEqualTo("hatsnad") + RefinedNysiisAlgorithm.compute("bart").get must beEqualTo("bad") + RefinedNysiisAlgorithm.compute("hurd").get must beEqualTo("had") + RefinedNysiisAlgorithm.compute("hunt").get must beEqualTo("had") + RefinedNysiisAlgorithm.compute("westerlund").get must beEqualTo("wastarlad") + RefinedNysiisAlgorithm.compute("evers").get must beEqualTo("evar") + RefinedNysiisAlgorithm.compute("devito").get must beEqualTo("dafat") + RefinedNysiisAlgorithm.compute("rawson").get must beEqualTo("rasan") + RefinedNysiisAlgorithm.compute("shoulders").get must beEqualTo("saldar") + RefinedNysiisAlgorithm.compute("leighton").get must beEqualTo("lagtan") + RefinedNysiisAlgorithm.compute("wooldridge").get must beEqualTo("waldrag") + RefinedNysiisAlgorithm.compute("oliphant").get must beEqualTo("olafad") + RefinedNysiisAlgorithm.compute("hatchett").get must beEqualTo("hatcat") + RefinedNysiisAlgorithm.compute("mcknight").get must beEqualTo("mcnagt") + RefinedNysiisAlgorithm.compute("rickert").get must beEqualTo("racad") + RefinedNysiisAlgorithm.compute("bowman").get must beEqualTo("banan") + RefinedNysiisAlgorithm.compute("vasquez").get must beEqualTo("vasg") + RefinedNysiisAlgorithm.compute("bashaw").get must beEqualTo("bas") + RefinedNysiisAlgorithm.compute("schoenhoeft").get must beEqualTo("sanaft") // dropby wrongly says scanaft + RefinedNysiisAlgorithm.compute("heywood").get must beEqualTo("had") + RefinedNysiisAlgorithm.compute("hayman").get must beEqualTo("hanan") + RefinedNysiisAlgorithm.compute("seawright").get must beEqualTo("saragt") + RefinedNysiisAlgorithm.compute("kratzer").get must beEqualTo("cratsar") + RefinedNysiisAlgorithm.compute("canaday").get must beEqualTo("canady") + RefinedNysiisAlgorithm.compute("crepeau").get must beEqualTo("crap") } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala index 8c6d9c1..285d879 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala @@ -1,35 +1,22 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - RefinedNysiisMetric.compare("", "").isDefined should be (false) - RefinedNysiisMetric.compare("abc", "").isDefined should be (false) - RefinedNysiisMetric.compare("", "xyz").isDefined should be (false) - } +object RefinedNysiisMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "RefinedNysiisMetric compare()" should { + "return None with empty arguments" in { + RefinedNysiisMetric.compare("", "").isDefined must beFalse + RefinedNysiisMetric.compare("abc", "").isDefined must beFalse + RefinedNysiisMetric.compare("", "xyz").isDefined must beFalse } - "non-phonetic arguments" should returns { - "None" in { - RefinedNysiisMetric.compare("123", "123").isDefined should be (false) - RefinedNysiisMetric.compare("123", "").isDefined should be (false) - RefinedNysiisMetric.compare("", "123").isDefined should be (false) - } + "return None with non-phonetic arguments" in { + RefinedNysiisMetric.compare("123", "123").isDefined must beFalse + RefinedNysiisMetric.compare("123", "").isDefined must beFalse + RefinedNysiisMetric.compare("", "123").isDefined must beFalse } - "phonetically similar arguments" should returns { - "Boolean indicating true" in { - RefinedNysiisMetric.compare("ham", "hum").get should be (true) - } + "return true with phonetically similar arguments" in { + RefinedNysiisMetric.compare("ham", "hum").get must beTrue } - "phonetically dissimilar arguments" should returns { - "Boolean indicating false" in { - RefinedNysiisMetric.compare("dumb", "gum").get should be (false) - } + "return false with phonetically dissimilar arguments" in { + RefinedNysiisMetric.compare("dumb", "gum").get must beFalse } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala index ca39da8..ff756fa 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala @@ -1,160 +1,149 @@ package com.rockymadden.stringmetric.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 { - "compute method" when passed { - "empty argument" should returns { - "None" in { - RefinedSoundexAlgorithm.compute("").isDefined should be (false) - } +object RefinedSoundexAlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "compute method" should { + "return None with empty argument" in { + RefinedSoundexAlgorithm.compute("").isDefined must beFalse } - "non-phonetic argument" should returns { - "None" in { - RefinedSoundexAlgorithm.compute("123").isDefined should be (false) - } + "return None with non-phonetic argument" in { + RefinedSoundexAlgorithm.compute("123").isDefined must beFalse } - "phonetic argument" should returns { - "Some" in { - // a - RefinedSoundexAlgorithm.compute("a").get should equal ("a0") - RefinedSoundexAlgorithm.compute("aa").get should equal ("a0") + "return Some with phonetic argument" in { + // a + RefinedSoundexAlgorithm.compute("a").get must beEqualTo("a0") + RefinedSoundexAlgorithm.compute("aa").get must beEqualTo("a0") - // b - RefinedSoundexAlgorithm.compute("b").get should equal ("b1") - RefinedSoundexAlgorithm.compute("bb").get should equal ("b1") - - // c - RefinedSoundexAlgorithm.compute("c").get should equal ("c3") - RefinedSoundexAlgorithm.compute("cc").get should equal ("c3") - - // d - RefinedSoundexAlgorithm.compute("d").get should equal ("d6") - RefinedSoundexAlgorithm.compute("dd").get should equal ("d6") - - // e - RefinedSoundexAlgorithm.compute("e").get should equal ("e0") - RefinedSoundexAlgorithm.compute("ee").get should equal ("e0") - - // f - RefinedSoundexAlgorithm.compute("f").get should equal ("f2") - RefinedSoundexAlgorithm.compute("ff").get should equal ("f2") - - // g - RefinedSoundexAlgorithm.compute("g").get should equal ("g4") - RefinedSoundexAlgorithm.compute("gg").get should equal ("g4") - - // h - RefinedSoundexAlgorithm.compute("h").get should equal ("h0") - RefinedSoundexAlgorithm.compute("hh").get should equal ("h0") - - // i - RefinedSoundexAlgorithm.compute("i").get should equal ("i0") - RefinedSoundexAlgorithm.compute("ii").get should equal ("i0") - - // j - RefinedSoundexAlgorithm.compute("j").get should equal ("j4") - RefinedSoundexAlgorithm.compute("jj").get should equal ("j4") - - // k - RefinedSoundexAlgorithm.compute("k").get should equal ("k3") - RefinedSoundexAlgorithm.compute("kk").get should equal ("k3") - - // l - RefinedSoundexAlgorithm.compute("l").get should equal ("l7") - RefinedSoundexAlgorithm.compute("ll").get should equal ("l7") - - // m - RefinedSoundexAlgorithm.compute("m").get should equal ("m8") - RefinedSoundexAlgorithm.compute("mm").get should equal ("m8") - - // n - RefinedSoundexAlgorithm.compute("n").get should equal ("n8") - RefinedSoundexAlgorithm.compute("nn").get should equal ("n8") - - // o - RefinedSoundexAlgorithm.compute("o").get should equal ("o0") - RefinedSoundexAlgorithm.compute("oo").get should equal ("o0") - - // p - RefinedSoundexAlgorithm.compute("p").get should equal ("p1") - RefinedSoundexAlgorithm.compute("pp").get should equal ("p1") - - // q - RefinedSoundexAlgorithm.compute("q").get should equal ("q5") - RefinedSoundexAlgorithm.compute("qq").get should equal ("q5") - - // r - RefinedSoundexAlgorithm.compute("r").get should equal ("r9") - RefinedSoundexAlgorithm.compute("rr").get should equal ("r9") - - // s - RefinedSoundexAlgorithm.compute("s").get should equal ("s3") - RefinedSoundexAlgorithm.compute("ss").get should equal ("s3") - - // t - RefinedSoundexAlgorithm.compute("t").get should equal ("t6") - RefinedSoundexAlgorithm.compute("tt").get should equal ("t6") - - // u - RefinedSoundexAlgorithm.compute("u").get should equal ("u0") - RefinedSoundexAlgorithm.compute("uu").get should equal ("u0") - - // v - RefinedSoundexAlgorithm.compute("v").get should equal ("v2") - RefinedSoundexAlgorithm.compute("vv").get should equal ("v2") - - // w - RefinedSoundexAlgorithm.compute("w").get should equal ("w0") - RefinedSoundexAlgorithm.compute("ww").get should equal ("w0") - - // x - RefinedSoundexAlgorithm.compute("x").get should equal ("x5") - RefinedSoundexAlgorithm.compute("xx").get should equal ("x5") - - // y - RefinedSoundexAlgorithm.compute("y").get should equal ("y0") - RefinedSoundexAlgorithm.compute("yy").get should equal ("y0") - - // z - RefinedSoundexAlgorithm.compute("z").get should equal ("z5") - RefinedSoundexAlgorithm.compute("zz").get should equal ("z5") - - // Starting with letter then numbers. - RefinedSoundexAlgorithm.compute("x123456").get should equal ("x5") - RefinedSoundexAlgorithm.compute("a123456").get should equal ("a0") - RefinedSoundexAlgorithm.compute("f123456").get should equal ("f2") - - // Miscellaneous. - RefinedSoundexAlgorithm.compute("braz").get should equal ("b1905") - RefinedSoundexAlgorithm.compute("broz").get should equal ("b1905") - RefinedSoundexAlgorithm.compute("caren").get should equal ("c30908") - RefinedSoundexAlgorithm.compute("carren").get should equal ("c30908") - RefinedSoundexAlgorithm.compute("coram").get should equal ("c30908") - RefinedSoundexAlgorithm.compute("corran").get should equal ("c30908") - RefinedSoundexAlgorithm.compute("curreen").get should equal ("c30908") - RefinedSoundexAlgorithm.compute("curwen").get should equal ("c30908") - RefinedSoundexAlgorithm.compute("hairs").get should equal ("h093") - RefinedSoundexAlgorithm.compute("hark").get should equal ("h093") - RefinedSoundexAlgorithm.compute("hars").get should equal ("h093") - RefinedSoundexAlgorithm.compute("hayers").get should equal ("h093") - RefinedSoundexAlgorithm.compute("heers").get should equal ("h093") - RefinedSoundexAlgorithm.compute("hiers").get should equal ("h093") - RefinedSoundexAlgorithm.compute("lambard").get should equal ("l7081096") - RefinedSoundexAlgorithm.compute("lambart").get should equal ("l7081096") - RefinedSoundexAlgorithm.compute("lambert").get should equal ("l7081096") - RefinedSoundexAlgorithm.compute("lambird").get should equal ("l7081096") - RefinedSoundexAlgorithm.compute("lampaert").get should equal ("l7081096") - RefinedSoundexAlgorithm.compute("lampart").get should equal ("l7081096") - RefinedSoundexAlgorithm.compute("lamport").get should equal ("l7081096") - RefinedSoundexAlgorithm.compute("limbert").get should equal ("l7081096") - RefinedSoundexAlgorithm.compute("lombard").get should equal ("l7081096") - RefinedSoundexAlgorithm.compute("nolton").get should equal ("n807608") - RefinedSoundexAlgorithm.compute("noulton").get should equal ("n807608") - } + // b + RefinedSoundexAlgorithm.compute("b").get must beEqualTo("b1") + RefinedSoundexAlgorithm.compute("bb").get must beEqualTo("b1") + + // c + RefinedSoundexAlgorithm.compute("c").get must beEqualTo("c3") + RefinedSoundexAlgorithm.compute("cc").get must beEqualTo("c3") + + // d + RefinedSoundexAlgorithm.compute("d").get must beEqualTo("d6") + RefinedSoundexAlgorithm.compute("dd").get must beEqualTo("d6") + + // e + RefinedSoundexAlgorithm.compute("e").get must beEqualTo("e0") + RefinedSoundexAlgorithm.compute("ee").get must beEqualTo("e0") + + // f + RefinedSoundexAlgorithm.compute("f").get must beEqualTo("f2") + RefinedSoundexAlgorithm.compute("ff").get must beEqualTo("f2") + + // g + RefinedSoundexAlgorithm.compute("g").get must beEqualTo("g4") + RefinedSoundexAlgorithm.compute("gg").get must beEqualTo("g4") + + // h + RefinedSoundexAlgorithm.compute("h").get must beEqualTo("h0") + RefinedSoundexAlgorithm.compute("hh").get must beEqualTo("h0") + + // i + RefinedSoundexAlgorithm.compute("i").get must beEqualTo("i0") + RefinedSoundexAlgorithm.compute("ii").get must beEqualTo("i0") + + // j + RefinedSoundexAlgorithm.compute("j").get must beEqualTo("j4") + RefinedSoundexAlgorithm.compute("jj").get must beEqualTo("j4") + + // k + RefinedSoundexAlgorithm.compute("k").get must beEqualTo("k3") + RefinedSoundexAlgorithm.compute("kk").get must beEqualTo("k3") + + // l + RefinedSoundexAlgorithm.compute("l").get must beEqualTo("l7") + RefinedSoundexAlgorithm.compute("ll").get must beEqualTo("l7") + + // m + RefinedSoundexAlgorithm.compute("m").get must beEqualTo("m8") + RefinedSoundexAlgorithm.compute("mm").get must beEqualTo("m8") + + // n + RefinedSoundexAlgorithm.compute("n").get must beEqualTo("n8") + RefinedSoundexAlgorithm.compute("nn").get must beEqualTo("n8") + + // o + RefinedSoundexAlgorithm.compute("o").get must beEqualTo("o0") + RefinedSoundexAlgorithm.compute("oo").get must beEqualTo("o0") + + // p + RefinedSoundexAlgorithm.compute("p").get must beEqualTo("p1") + RefinedSoundexAlgorithm.compute("pp").get must beEqualTo("p1") + + // q + RefinedSoundexAlgorithm.compute("q").get must beEqualTo("q5") + RefinedSoundexAlgorithm.compute("qq").get must beEqualTo("q5") + + // r + RefinedSoundexAlgorithm.compute("r").get must beEqualTo("r9") + RefinedSoundexAlgorithm.compute("rr").get must beEqualTo("r9") + + // s + RefinedSoundexAlgorithm.compute("s").get must beEqualTo("s3") + RefinedSoundexAlgorithm.compute("ss").get must beEqualTo("s3") + + // t + RefinedSoundexAlgorithm.compute("t").get must beEqualTo("t6") + RefinedSoundexAlgorithm.compute("tt").get must beEqualTo("t6") + + // u + RefinedSoundexAlgorithm.compute("u").get must beEqualTo("u0") + RefinedSoundexAlgorithm.compute("uu").get must beEqualTo("u0") + + // v + RefinedSoundexAlgorithm.compute("v").get must beEqualTo("v2") + RefinedSoundexAlgorithm.compute("vv").get must beEqualTo("v2") + + // w + RefinedSoundexAlgorithm.compute("w").get must beEqualTo("w0") + RefinedSoundexAlgorithm.compute("ww").get must beEqualTo("w0") + + // x + RefinedSoundexAlgorithm.compute("x").get must beEqualTo("x5") + RefinedSoundexAlgorithm.compute("xx").get must beEqualTo("x5") + + // y + RefinedSoundexAlgorithm.compute("y").get must beEqualTo("y0") + RefinedSoundexAlgorithm.compute("yy").get must beEqualTo("y0") + + // z + RefinedSoundexAlgorithm.compute("z").get must beEqualTo("z5") + RefinedSoundexAlgorithm.compute("zz").get must beEqualTo("z5") + + // Starting with letter then numbers. + RefinedSoundexAlgorithm.compute("x123456").get must beEqualTo("x5") + RefinedSoundexAlgorithm.compute("a123456").get must beEqualTo("a0") + RefinedSoundexAlgorithm.compute("f123456").get must beEqualTo("f2") + + // Miscellaneous. + RefinedSoundexAlgorithm.compute("braz").get must beEqualTo("b1905") + RefinedSoundexAlgorithm.compute("broz").get must beEqualTo("b1905") + RefinedSoundexAlgorithm.compute("caren").get must beEqualTo("c30908") + RefinedSoundexAlgorithm.compute("carren").get must beEqualTo("c30908") + RefinedSoundexAlgorithm.compute("coram").get must beEqualTo("c30908") + RefinedSoundexAlgorithm.compute("corran").get must beEqualTo("c30908") + RefinedSoundexAlgorithm.compute("curreen").get must beEqualTo("c30908") + RefinedSoundexAlgorithm.compute("curwen").get must beEqualTo("c30908") + RefinedSoundexAlgorithm.compute("hairs").get must beEqualTo("h093") + RefinedSoundexAlgorithm.compute("hark").get must beEqualTo("h093") + RefinedSoundexAlgorithm.compute("hars").get must beEqualTo("h093") + RefinedSoundexAlgorithm.compute("hayers").get must beEqualTo("h093") + RefinedSoundexAlgorithm.compute("heers").get must beEqualTo("h093") + RefinedSoundexAlgorithm.compute("hiers").get must beEqualTo("h093") + RefinedSoundexAlgorithm.compute("lambard").get must beEqualTo("l7081096") + RefinedSoundexAlgorithm.compute("lambart").get must beEqualTo("l7081096") + RefinedSoundexAlgorithm.compute("lambert").get must beEqualTo("l7081096") + RefinedSoundexAlgorithm.compute("lambird").get must beEqualTo("l7081096") + RefinedSoundexAlgorithm.compute("lampaert").get must beEqualTo("l7081096") + RefinedSoundexAlgorithm.compute("lampart").get must beEqualTo("l7081096") + RefinedSoundexAlgorithm.compute("lamport").get must beEqualTo("l7081096") + RefinedSoundexAlgorithm.compute("limbert").get must beEqualTo("l7081096") + RefinedSoundexAlgorithm.compute("lombard").get must beEqualTo("l7081096") + RefinedSoundexAlgorithm.compute("nolton").get must beEqualTo("n807608") + RefinedSoundexAlgorithm.compute("noulton").get must beEqualTo("n807608") } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala index 84f547a..82ff3fa 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala @@ -1,35 +1,22 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - RefinedSoundexMetric.compare("", "").isDefined should be (false) - RefinedSoundexMetric.compare("abc", "").isDefined should be (false) - RefinedSoundexMetric.compare("", "xyz").isDefined should be (false) - } +object RefinedSoundexMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "RefinedSoundexMetric compare()" should { + "return None with empty arguments" in { + RefinedSoundexMetric.compare("", "").isDefined must beFalse + RefinedSoundexMetric.compare("abc", "").isDefined must beFalse + RefinedSoundexMetric.compare("", "xyz").isDefined must beFalse } - "non-phonetic arguments" should returns { - "None" in { - RefinedSoundexMetric.compare("123", "123").isDefined should be (false) - RefinedSoundexMetric.compare("123", "").isDefined should be (false) - RefinedSoundexMetric.compare("", "123").isDefined should be (false) - } + "return None with non-phonetic arguments" in { + RefinedSoundexMetric.compare("123", "123").isDefined must beFalse + RefinedSoundexMetric.compare("123", "").isDefined must beFalse + RefinedSoundexMetric.compare("", "123").isDefined must beFalse } - "phonetically similar arguments" should returns { - "Boolean indicating true" in { - RefinedSoundexMetric.compare("robert", "rupert").get should be (true) - } + "return true with phonetically similar arguments" in { + RefinedSoundexMetric.compare("robert", "rupert").get must beTrue } - "phonetically dissimilar arguments" should returns { - "Boolean indicating false" in { - RefinedSoundexMetric.compare("robert", "rubin").get should be (false) - } + "return false with phonetically dissimilar arguments" in { + RefinedSoundexMetric.compare("robert", "rubin").get must beFalse } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala index 157a24b..c167f63 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala @@ -1,159 +1,148 @@ package com.rockymadden.stringmetric.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 { - "compute method" when passed { - "empty argument" should returns { - "None" in { - SoundexAlgorithm.compute("").isDefined should be (false) - } +object SoundexAlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "SoundexAlgorithm compute()" should { + "return None with empty argument" in { + SoundexAlgorithm.compute("").isDefined must beFalse } - "non-phonetic argument" should returns { - "None" in { - SoundexAlgorithm.compute("123").isDefined should be (false) - } + "return None with non-phonetic argument" in { + SoundexAlgorithm.compute("123").isDefined must beFalse } - "phonetic argument" should returns { - "Some" in { - // a - SoundexAlgorithm.compute("a").get should equal ("a000") - SoundexAlgorithm.compute("aa").get should equal ("a000") + "return Some with phonetic argument" in { + // a + SoundexAlgorithm.compute("a").get must beEqualTo("a000") + SoundexAlgorithm.compute("aa").get must beEqualTo("a000") - // b - SoundexAlgorithm.compute("b").get should equal ("b000") - SoundexAlgorithm.compute("bb").get should equal ("b000") - - // c - SoundexAlgorithm.compute("c").get should equal ("c000") - SoundexAlgorithm.compute("cc").get should equal ("c000") - - // d - SoundexAlgorithm.compute("d").get should equal ("d000") - SoundexAlgorithm.compute("dd").get should equal ("d000") - - // e - SoundexAlgorithm.compute("e").get should equal ("e000") - SoundexAlgorithm.compute("ee").get should equal ("e000") - - // f - SoundexAlgorithm.compute("f").get should equal ("f000") - SoundexAlgorithm.compute("ff").get should equal ("f000") - - // g - SoundexAlgorithm.compute("g").get should equal ("g000") - SoundexAlgorithm.compute("gg").get should equal ("g000") - - // h - SoundexAlgorithm.compute("h").get should equal ("h000") - SoundexAlgorithm.compute("hh").get should equal ("h000") - - // i - SoundexAlgorithm.compute("i").get should equal ("i000") - SoundexAlgorithm.compute("ii").get should equal ("i000") - - // j - SoundexAlgorithm.compute("j").get should equal ("j000") - SoundexAlgorithm.compute("jj").get should equal ("j000") - - // k - SoundexAlgorithm.compute("k").get should equal ("k000") - SoundexAlgorithm.compute("kk").get should equal ("k000") - - // l - SoundexAlgorithm.compute("l").get should equal ("l000") - SoundexAlgorithm.compute("ll").get should equal ("l000") - - // m - SoundexAlgorithm.compute("m").get should equal ("m000") - SoundexAlgorithm.compute("mm").get should equal ("m000") - - // n - SoundexAlgorithm.compute("n").get should equal ("n000") - SoundexAlgorithm.compute("nn").get should equal ("n000") - - // o - SoundexAlgorithm.compute("o").get should equal ("o000") - SoundexAlgorithm.compute("oo").get should equal ("o000") - - // p - SoundexAlgorithm.compute("p").get should equal ("p000") - SoundexAlgorithm.compute("pp").get should equal ("p000") - - // q - SoundexAlgorithm.compute("q").get should equal ("q000") - SoundexAlgorithm.compute("qq").get should equal ("q000") - - // r - SoundexAlgorithm.compute("r").get should equal ("r000") - SoundexAlgorithm.compute("rr").get should equal ("r000") - - // s - SoundexAlgorithm.compute("s").get should equal ("s000") - SoundexAlgorithm.compute("ss").get should equal ("s000") - - // t - SoundexAlgorithm.compute("t").get should equal ("t000") - SoundexAlgorithm.compute("tt").get should equal ("t000") - - // u - SoundexAlgorithm.compute("u").get should equal ("u000") - SoundexAlgorithm.compute("uu").get should equal ("u000") - - // v - SoundexAlgorithm.compute("v").get should equal ("v000") - SoundexAlgorithm.compute("vv").get should equal ("v000") - - // w - SoundexAlgorithm.compute("w").get should equal ("w000") - SoundexAlgorithm.compute("ww").get should equal ("w000") - - // x - SoundexAlgorithm.compute("x").get should equal ("x000") - SoundexAlgorithm.compute("xx").get should equal ("x000") - - // y - SoundexAlgorithm.compute("y").get should equal ("y000") - SoundexAlgorithm.compute("yy").get should equal ("y000") - - // z - SoundexAlgorithm.compute("z").get should equal ("z000") - SoundexAlgorithm.compute("zz").get should equal ("z000") - - // Starting with letter then numbers. - SoundexAlgorithm.compute("x123456").get should equal ("x000") - SoundexAlgorithm.compute("a123456").get should equal ("a000") - SoundexAlgorithm.compute("f123456").get should equal ("f000") - - // Miscellaneous. - SoundexAlgorithm.compute("abc").get should equal ("a120") - SoundexAlgorithm.compute("xyz").get should equal ("x200") - SoundexAlgorithm.compute("robert").get should equal ("r163") - SoundexAlgorithm.compute("rupert").get should equal ("r163") - SoundexAlgorithm.compute("rubin").get should equal ("r150") - SoundexAlgorithm.compute("ashcraft").get should equal ("a261") - SoundexAlgorithm.compute("tymczak").get should equal ("t522") - SoundexAlgorithm.compute("pfister").get should equal ("p236") - SoundexAlgorithm.compute("euler").get should equal ("e460") - SoundexAlgorithm.compute("gauss").get should equal ("g200") - SoundexAlgorithm.compute("hilbert").get should equal ("h416") - SoundexAlgorithm.compute("knuth").get should equal ("k530") - SoundexAlgorithm.compute("lloyd").get should equal ("l300") - SoundexAlgorithm.compute("lukasiewicz").get should equal ("l222") - SoundexAlgorithm.compute("ashcroft").get should equal ("a261") - SoundexAlgorithm.compute("tymczak").get should equal ("t522") - SoundexAlgorithm.compute("pfister").get should equal ("p236") - SoundexAlgorithm.compute("ellery").get should equal ("e460") - SoundexAlgorithm.compute("ghosh").get should equal ("g200") - SoundexAlgorithm.compute("heilbronn").get should equal ("h416") - SoundexAlgorithm.compute("kant").get should equal ("k530") - SoundexAlgorithm.compute("ladd").get should equal ("l300") - SoundexAlgorithm.compute("lissajous").get should equal ("l222") - SoundexAlgorithm.compute("fusedale").get should equal ("f234") - } + // b + SoundexAlgorithm.compute("b").get must beEqualTo("b000") + SoundexAlgorithm.compute("bb").get must beEqualTo("b000") + + // c + SoundexAlgorithm.compute("c").get must beEqualTo("c000") + SoundexAlgorithm.compute("cc").get must beEqualTo("c000") + + // d + SoundexAlgorithm.compute("d").get must beEqualTo("d000") + SoundexAlgorithm.compute("dd").get must beEqualTo("d000") + + // e + SoundexAlgorithm.compute("e").get must beEqualTo("e000") + SoundexAlgorithm.compute("ee").get must beEqualTo("e000") + + // f + SoundexAlgorithm.compute("f").get must beEqualTo("f000") + SoundexAlgorithm.compute("ff").get must beEqualTo("f000") + + // g + SoundexAlgorithm.compute("g").get must beEqualTo("g000") + SoundexAlgorithm.compute("gg").get must beEqualTo("g000") + + // h + SoundexAlgorithm.compute("h").get must beEqualTo("h000") + SoundexAlgorithm.compute("hh").get must beEqualTo("h000") + + // i + SoundexAlgorithm.compute("i").get must beEqualTo("i000") + SoundexAlgorithm.compute("ii").get must beEqualTo("i000") + + // j + SoundexAlgorithm.compute("j").get must beEqualTo("j000") + SoundexAlgorithm.compute("jj").get must beEqualTo("j000") + + // k + SoundexAlgorithm.compute("k").get must beEqualTo("k000") + SoundexAlgorithm.compute("kk").get must beEqualTo("k000") + + // l + SoundexAlgorithm.compute("l").get must beEqualTo("l000") + SoundexAlgorithm.compute("ll").get must beEqualTo("l000") + + // m + SoundexAlgorithm.compute("m").get must beEqualTo("m000") + SoundexAlgorithm.compute("mm").get must beEqualTo("m000") + + // n + SoundexAlgorithm.compute("n").get must beEqualTo("n000") + SoundexAlgorithm.compute("nn").get must beEqualTo("n000") + + // o + SoundexAlgorithm.compute("o").get must beEqualTo("o000") + SoundexAlgorithm.compute("oo").get must beEqualTo("o000") + + // p + SoundexAlgorithm.compute("p").get must beEqualTo("p000") + SoundexAlgorithm.compute("pp").get must beEqualTo("p000") + + // q + SoundexAlgorithm.compute("q").get must beEqualTo("q000") + SoundexAlgorithm.compute("qq").get must beEqualTo("q000") + + // r + SoundexAlgorithm.compute("r").get must beEqualTo("r000") + SoundexAlgorithm.compute("rr").get must beEqualTo("r000") + + // s + SoundexAlgorithm.compute("s").get must beEqualTo("s000") + SoundexAlgorithm.compute("ss").get must beEqualTo("s000") + + // t + SoundexAlgorithm.compute("t").get must beEqualTo("t000") + SoundexAlgorithm.compute("tt").get must beEqualTo("t000") + + // u + SoundexAlgorithm.compute("u").get must beEqualTo("u000") + SoundexAlgorithm.compute("uu").get must beEqualTo("u000") + + // v + SoundexAlgorithm.compute("v").get must beEqualTo("v000") + SoundexAlgorithm.compute("vv").get must beEqualTo("v000") + + // w + SoundexAlgorithm.compute("w").get must beEqualTo("w000") + SoundexAlgorithm.compute("ww").get must beEqualTo("w000") + + // x + SoundexAlgorithm.compute("x").get must beEqualTo("x000") + SoundexAlgorithm.compute("xx").get must beEqualTo("x000") + + // y + SoundexAlgorithm.compute("y").get must beEqualTo("y000") + SoundexAlgorithm.compute("yy").get must beEqualTo("y000") + + // z + SoundexAlgorithm.compute("z").get must beEqualTo("z000") + SoundexAlgorithm.compute("zz").get must beEqualTo("z000") + + // Starting with letter then numbers. + SoundexAlgorithm.compute("x123456").get must beEqualTo("x000") + SoundexAlgorithm.compute("a123456").get must beEqualTo("a000") + SoundexAlgorithm.compute("f123456").get must beEqualTo("f000") + + // Miscellaneous. + SoundexAlgorithm.compute("abc").get must beEqualTo("a120") + SoundexAlgorithm.compute("xyz").get must beEqualTo("x200") + SoundexAlgorithm.compute("robert").get must beEqualTo("r163") + SoundexAlgorithm.compute("rupert").get must beEqualTo("r163") + SoundexAlgorithm.compute("rubin").get must beEqualTo("r150") + SoundexAlgorithm.compute("ashcraft").get must beEqualTo("a261") + SoundexAlgorithm.compute("tymczak").get must beEqualTo("t522") + SoundexAlgorithm.compute("pfister").get must beEqualTo("p236") + SoundexAlgorithm.compute("euler").get must beEqualTo("e460") + SoundexAlgorithm.compute("gauss").get must beEqualTo("g200") + SoundexAlgorithm.compute("hilbert").get must beEqualTo("h416") + SoundexAlgorithm.compute("knuth").get must beEqualTo("k530") + SoundexAlgorithm.compute("lloyd").get must beEqualTo("l300") + SoundexAlgorithm.compute("lukasiewicz").get must beEqualTo("l222") + SoundexAlgorithm.compute("ashcroft").get must beEqualTo("a261") + SoundexAlgorithm.compute("tymczak").get must beEqualTo("t522") + SoundexAlgorithm.compute("pfister").get must beEqualTo("p236") + SoundexAlgorithm.compute("ellery").get must beEqualTo("e460") + SoundexAlgorithm.compute("ghosh").get must beEqualTo("g200") + SoundexAlgorithm.compute("heilbronn").get must beEqualTo("h416") + SoundexAlgorithm.compute("kant").get must beEqualTo("k530") + SoundexAlgorithm.compute("ladd").get must beEqualTo("l300") + SoundexAlgorithm.compute("lissajous").get must beEqualTo("l222") + SoundexAlgorithm.compute("fusedale").get must beEqualTo("f234") } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala index b903add..449091d 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala @@ -1,35 +1,22 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - SoundexMetric.compare("", "").isDefined should be (false) - SoundexMetric.compare("abc", "").isDefined should be (false) - SoundexMetric.compare("", "xyz").isDefined should be (false) - } +object SoundexMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "SoundexMetric compare()" should { + "return None with empty arguments" in { + SoundexMetric.compare("", "").isDefined must beFalse + SoundexMetric.compare("abc", "").isDefined must beFalse + SoundexMetric.compare("", "xyz").isDefined must beFalse } - "non-phonetic arguments" should returns { - "None" in { - SoundexMetric.compare("123", "123").isDefined should be (false) - SoundexMetric.compare("123", "").isDefined should be (false) - SoundexMetric.compare("", "123").isDefined should be (false) - } + "return None with non-phonetic arguments" in { + SoundexMetric.compare("123", "123").isDefined must beFalse + SoundexMetric.compare("123", "").isDefined must beFalse + SoundexMetric.compare("", "123").isDefined must beFalse } - "phonetically similar arguments" should returns { - "Boolean indicating true" in { - SoundexMetric.compare("robert", "rupert").get should be (true) - } + "return true with phonetically similar arguments" in { + SoundexMetric.compare("robert", "rupert").get must beTrue } - "phonetically dissimilar arguments" should returns { - "Boolean indicating false" in { - SoundexMetric.compare("robert", "rubin").get should be (false) - } + "return false with phonetically dissimilar arguments" in { + SoundexMetric.compare("robert", "rubin").get must beFalse } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala index b7a3b58..4912e9e 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala @@ -1,60 +1,45 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - DiceSorensenMetric(1).compare("", "").isDefined should be (false) - DiceSorensenMetric(1).compare("abc", "").isDefined should be (false) - DiceSorensenMetric(1).compare("", "xyz").isDefined should be (false) - } +object DiceSorensenMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "DiceSorensenMetric compare()" should { + "return None with empty arguments" in { + DiceSorensenMetric(1).compare("", "").isDefined must beFalse + DiceSorensenMetric(1).compare("abc", "").isDefined must beFalse + DiceSorensenMetric(1).compare("", "xyz").isDefined must beFalse } - "equal arguments" should returns { - "1" in { - DiceSorensenMetric(1).compare("abc", "abc").get should be (1) - DiceSorensenMetric(2).compare("abc", "abc").get should be (1) - DiceSorensenMetric(2).compare("abc", "abc").get should be (1) - } + "return 1 with equal arguments" in { + DiceSorensenMetric(1).compare("abc", "abc").get must beEqualTo(1) + DiceSorensenMetric(2).compare("abc", "abc").get must beEqualTo(1) + DiceSorensenMetric(2).compare("abc", "abc").get must beEqualTo(1) } - "unequal arguments" should returns { - "0" in { - DiceSorensenMetric(1).compare("abc", "xyz").get should be (0) - DiceSorensenMetric(2).compare("abc", "xyz").get should be (0) - DiceSorensenMetric(3).compare("abc", "xyz").get should be (0) - } + "return 0 with unequal arguments" in { + DiceSorensenMetric(1).compare("abc", "xyz").get must beEqualTo(0) + DiceSorensenMetric(2).compare("abc", "xyz").get must beEqualTo(0) + DiceSorensenMetric(3).compare("abc", "xyz").get must beEqualTo(0) } - "invalid arguments" should returns { - "None" in { - DiceSorensenMetric(2).compare("n", "naght").isDefined should be (false) - DiceSorensenMetric(2).compare("night", "n").isDefined should be (false) - DiceSorensenMetric(3).compare("ni", "naght").isDefined should be (false) - DiceSorensenMetric(3).compare("night", "na").isDefined should be (false) - } + "return None with invalid arguments" in { + DiceSorensenMetric(2).compare("n", "naght").isDefined must beFalse + DiceSorensenMetric(2).compare("night", "n").isDefined must beFalse + DiceSorensenMetric(3).compare("ni", "naght").isDefined must beFalse + DiceSorensenMetric(3).compare("night", "na").isDefined must beFalse } - "valid arguments" should returns { - "Double indicating distance" in { - DiceSorensenMetric(1).compare("night", "nacht").get should be (0.6) - DiceSorensenMetric(1).compare("night", "naght").get should be (0.8) - DiceSorensenMetric(1).compare("context", "contact").get should be (0.7142857142857143) + "return distance with valid arguments" in { + DiceSorensenMetric(1).compare("night", "nacht").get must beEqualTo(0.6) + DiceSorensenMetric(1).compare("night", "naght").get must beEqualTo(0.8) + DiceSorensenMetric(1).compare("context", "contact").get must beEqualTo(0.7142857142857143) - DiceSorensenMetric(2).compare("night", "nacht").get should be (0.25) - DiceSorensenMetric(2).compare("night", "naght").get should be (0.5) - DiceSorensenMetric(2).compare("context", "contact").get should be (0.5) - DiceSorensenMetric(2).compare("contextcontext", "contact").get should be (0.3157894736842105) - DiceSorensenMetric(2).compare("context", "contactcontact").get should be (0.3157894736842105) - DiceSorensenMetric(2).compare("ht", "nacht").get should be (0.4) - DiceSorensenMetric(2).compare("xp", "nacht").get should be (0) - DiceSorensenMetric(2).compare("ht", "hththt").get should be (0.3333333333333333) + DiceSorensenMetric(2).compare("night", "nacht").get must beEqualTo(0.25) + DiceSorensenMetric(2).compare("night", "naght").get must beEqualTo(0.5) + DiceSorensenMetric(2).compare("context", "contact").get must beEqualTo(0.5) + DiceSorensenMetric(2).compare("contextcontext", "contact").get must beEqualTo(0.3157894736842105) + DiceSorensenMetric(2).compare("context", "contactcontact").get must beEqualTo(0.3157894736842105) + DiceSorensenMetric(2).compare("ht", "nacht").get must beEqualTo(0.4) + DiceSorensenMetric(2).compare("xp", "nacht").get must beEqualTo(0) + DiceSorensenMetric(2).compare("ht", "hththt").get must beEqualTo(0.3333333333333333) - DiceSorensenMetric(3).compare("night", "nacht").get should be (0) - DiceSorensenMetric(3).compare("night", "naght").get should be (0.3333333333333333) - DiceSorensenMetric(3).compare("context", "contact").get should be (0.4) - } + DiceSorensenMetric(3).compare("night", "nacht").get must beEqualTo(0) + DiceSorensenMetric(3).compare("night", "naght").get must beEqualTo(0.3333333333333333) + DiceSorensenMetric(3).compare("context", "contact").get must beEqualTo(0.4) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala index abb56db..b2831bc 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala @@ -1,37 +1,24 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - HammingMetric.compare("", "").isDefined should be (false) - HammingMetric.compare("abc", "").isDefined should be (false) - HammingMetric.compare("", "xyz").isDefined should be (false) - } +object HammingMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "HammingMetric compare()" should { + "return None with empty arguments" in { + HammingMetric.compare("", "").isDefined must beFalse + HammingMetric.compare("abc", "").isDefined must beFalse + HammingMetric.compare("", "xyz").isDefined must beFalse } - "equal arguments" should returns { - "0" in { - HammingMetric.compare("abc", "abc").get should be (0) - HammingMetric.compare("123", "123").get should be (0) - } + "return 0 with equal arguments" in { + HammingMetric.compare("abc", "abc").get must beEqualTo(0) + HammingMetric.compare("123", "123").get must beEqualTo(0) } - "unequal arguments" should returns { - "Int indicating distance" in { - HammingMetric.compare("abc", "xyz").get should be (3) - HammingMetric.compare("123", "456").get should be (3) - } + "return distance with unequal arguments" in { + HammingMetric.compare("abc", "xyz").get must beEqualTo(3) + HammingMetric.compare("123", "456").get must beEqualTo(3) } - "valid arguments" should returns { - "Int indicating distance" in { - HammingMetric.compare("toned", "roses").get should be (3) - HammingMetric.compare("1011101", "1001001").get should be (2) - HammingMetric.compare("2173896", "2233796").get should be (3) - } + "return distance with valid arguments" in { + HammingMetric.compare("toned", "roses").get must beEqualTo(3) + HammingMetric.compare("1011101", "1001001").get must beEqualTo(2) + HammingMetric.compare("2173896", "2233796").get must beEqualTo(3) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala index 4c04193..145a1e9 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala @@ -1,60 +1,45 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - JaccardMetric(1).compare("", "").isDefined should be (false) - JaccardMetric(1).compare("abc", "").isDefined should be (false) - JaccardMetric(1).compare("", "xyz").isDefined should be (false) - } +object JaccardMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "JaccardMetric compare()" should { + "return None with empty arguments" in { + JaccardMetric(1).compare("", "").isDefined must beFalse + JaccardMetric(1).compare("abc", "").isDefined must beFalse + JaccardMetric(1).compare("", "xyz").isDefined must beFalse } - "equal arguments" should returns { - "1" in { - JaccardMetric(1).compare("abc", "abc").get should be (1) - JaccardMetric(2).compare("abc", "abc").get should be (1) - JaccardMetric(3).compare("abc", "abc").get should be (1) - } + "return 1 with equal arguments" in { + JaccardMetric(1).compare("abc", "abc").get must beEqualTo(1) + JaccardMetric(2).compare("abc", "abc").get must beEqualTo(1) + JaccardMetric(3).compare("abc", "abc").get must beEqualTo(1) } - "unequal arguments" should returns { - "0" in { - JaccardMetric(1).compare("abc", "xyz").get should be (0) - JaccardMetric(2).compare("abc", "xyz").get should be (0) - JaccardMetric(3).compare("abc", "xyz").get should be (0) - } + "return 0 with unequal arguments" in { + JaccardMetric(1).compare("abc", "xyz").get must beEqualTo(0) + JaccardMetric(2).compare("abc", "xyz").get must beEqualTo(0) + JaccardMetric(3).compare("abc", "xyz").get must beEqualTo(0) } - "invalid arguments" should returns { - "None" in { - JaccardMetric(2).compare("n", "naght").isDefined should be (false) - JaccardMetric(2).compare("night", "n").isDefined should be (false) - JaccardMetric(3).compare("ni", "naght").isDefined should be (false) - JaccardMetric(3).compare("night", "na").isDefined should be (false) - } + "return None with invalid arguments" in { + JaccardMetric(2).compare("n", "naght").isDefined must beFalse + JaccardMetric(2).compare("night", "n").isDefined must beFalse + JaccardMetric(3).compare("ni", "naght").isDefined must beFalse + JaccardMetric(3).compare("night", "na").isDefined must beFalse } - "valid arguments" should returns { - "Double indicating distance" in { - JaccardMetric(1).compare("night", "nacht").get should be (0.42857142857142855) - JaccardMetric(1).compare("night", "naght").get should be (0.6666666666666666) - JaccardMetric(1).compare("context", "contact").get should be (0.5555555555555556) + "return distance with valid arguments" in { + JaccardMetric(1).compare("night", "nacht").get must beEqualTo(0.42857142857142855) + JaccardMetric(1).compare("night", "naght").get must beEqualTo(0.6666666666666666) + JaccardMetric(1).compare("context", "contact").get must beEqualTo(0.5555555555555556) - JaccardMetric(2).compare("night", "nacht").get should be (0.14285714285714285) - JaccardMetric(2).compare("night", "naght").get should be (0.3333333333333333) - JaccardMetric(2).compare("context", "contact").get should be (0.3333333333333333) - JaccardMetric(2).compare("contextcontext", "contact").get should be (0.1875) - JaccardMetric(2).compare("context", "contactcontact").get should be (0.1875) - JaccardMetric(2).compare("ht", "nacht").get should be (0.25) - JaccardMetric(2).compare("xp", "nacht").get should be (0) - JaccardMetric(2).compare("ht", "hththt").get should be (0.2) + JaccardMetric(2).compare("night", "nacht").get must beEqualTo(0.14285714285714285) + JaccardMetric(2).compare("night", "naght").get must beEqualTo(0.3333333333333333) + JaccardMetric(2).compare("context", "contact").get must beEqualTo(0.3333333333333333) + JaccardMetric(2).compare("contextcontext", "contact").get must beEqualTo(0.1875) + JaccardMetric(2).compare("context", "contactcontact").get must beEqualTo(0.1875) + JaccardMetric(2).compare("ht", "nacht").get must beEqualTo(0.25) + JaccardMetric(2).compare("xp", "nacht").get must beEqualTo(0) + JaccardMetric(2).compare("ht", "hththt").get must beEqualTo(0.2) - JaccardMetric(3).compare("night", "nacht").get should be (0) - JaccardMetric(3).compare("night", "naght").get should be (0.2) - JaccardMetric(3).compare("context", "contact").get should be (0.25) - } + JaccardMetric(3).compare("night", "nacht").get must beEqualTo(0) + JaccardMetric(3).compare("night", "naght").get must beEqualTo(0.2) + JaccardMetric(3).compare("context", "contact").get must beEqualTo(0.25) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala index 26ae38e..c445033 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala @@ -1,51 +1,38 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - JaroMetric.compare("", "").isDefined should be (false) - JaroMetric.compare("abc", "").isDefined should be (false) - JaroMetric.compare("", "xyz").isDefined should be (false) - } +object JaroMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "JaroMetric compare()" should { + "return None with empty arguments" in { + JaroMetric.compare("", "").isDefined should beFalse + JaroMetric.compare("abc", "").isDefined should beFalse + JaroMetric.compare("", "xyz").isDefined should beFalse } - "equal arguments" should returns { - "1" in { - JaroMetric.compare("a", "a").get should be (1) - JaroMetric.compare("abc", "abc").get should be (1) - JaroMetric.compare("123", "123").get should be (1) - } + "return 1 with equal arguments" in { + JaroMetric.compare("a", "a").get must beEqualTo(1) + JaroMetric.compare("abc", "abc").get must beEqualTo(1) + JaroMetric.compare("123", "123").get must beEqualTo(1) } - "unequal arguments" should returns { - "0" in { - JaroMetric.compare("abc", "xyz").get should be (0) - JaroMetric.compare("123", "456").get should be (0) - } + "return with 0 with unequal arguments" in { + JaroMetric.compare("abc", "xyz").get must beEqualTo(0) + JaroMetric.compare("123", "456").get must beEqualTo(0) } - "valid arguments" should returns { - "Double indicating distance" in { - JaroMetric.compare("aa", "a").get should be (0.8333333333333334) - JaroMetric.compare("a", "aa").get should be (0.8333333333333334) - JaroMetric.compare("veryveryverylong", "v").get should be (0.6875) - JaroMetric.compare("v", "veryveryverylong").get should be (0.6875) - JaroMetric.compare("martha", "marhta").get should be (0.9444444444444445) - JaroMetric.compare("dwayne", "duane").get should be (0.8222222222222223) - JaroMetric.compare("dixon", "dicksonx").get should be (0.7666666666666666) - JaroMetric.compare("abcvwxyz", "cabvwxyz").get should be (0.9583333333333334) - JaroMetric.compare("jones", "johnson").get should be (0.7904761904761904) - JaroMetric.compare("henka", "henkan").get should be (0.9444444444444445) - JaroMetric.compare("fvie", "ten").get should be (0) + "return distance with valid arguments" in { + JaroMetric.compare("aa", "a").get must beEqualTo(0.8333333333333334) + JaroMetric.compare("a", "aa").get must beEqualTo(0.8333333333333334) + JaroMetric.compare("veryveryverylong", "v").get must beEqualTo(0.6875) + JaroMetric.compare("v", "veryveryverylong").get must beEqualTo(0.6875) + JaroMetric.compare("martha", "marhta").get must beEqualTo(0.9444444444444445) + JaroMetric.compare("dwayne", "duane").get must beEqualTo(0.8222222222222223) + JaroMetric.compare("dixon", "dicksonx").get must beEqualTo(0.7666666666666666) + JaroMetric.compare("abcvwxyz", "cabvwxyz").get must beEqualTo(0.9583333333333334) + JaroMetric.compare("jones", "johnson").get must beEqualTo(0.7904761904761904) + JaroMetric.compare("henka", "henkan").get must beEqualTo(0.9444444444444445) + JaroMetric.compare("fvie", "ten").get must beEqualTo(0) - JaroMetric.compare("zac ephron", "zac efron").get should be > - JaroMetric.compare("zac ephron", "kai ephron").get - JaroMetric.compare("brittney spears", "britney spears").get should be > - JaroMetric.compare("brittney spears", "brittney startzman").get - } + JaroMetric.compare("zac ephron", "zac efron").get must + beGreaterThan(JaroMetric.compare("zac ephron", "kai ephron").get) + JaroMetric.compare("brittney spears", "britney spears").get must + beGreaterThan(JaroMetric.compare("brittney spears", "brittney startzman").get) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala index d645456..79a4df0 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala @@ -1,51 +1,38 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - JaroWinklerMetric.compare("", "").isDefined should be (false) - JaroWinklerMetric.compare("abc", "").isDefined should be (false) - JaroWinklerMetric.compare("", "xyz").isDefined should be (false) - } +object JaroWinklerMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "JaroWinklerMetric compare()" should { + "return None with empty arguments" in { + JaroWinklerMetric.compare("", "").isDefined must beFalse + JaroWinklerMetric.compare("abc", "").isDefined must beFalse + JaroWinklerMetric.compare("", "xyz").isDefined must beFalse } - "equal arguments" should returns { - "1" in { - JaroWinklerMetric.compare("a", "a").get should be (1) - JaroWinklerMetric.compare("abc", "abc").get should be (1) - JaroWinklerMetric.compare("123", "123").get should be (1) - } + "return 1 with equal arguments" in { + JaroWinklerMetric.compare("a", "a").get must beEqualTo(1) + JaroWinklerMetric.compare("abc", "abc").get must beEqualTo(1) + JaroWinklerMetric.compare("123", "123").get must beEqualTo(1) } - "unequal arguments" should returns { - "0" in { - JaroWinklerMetric.compare("abc", "xyz").get should be (0) - JaroWinklerMetric.compare("123", "456").get should be (0) - } + "return 0 with unequal arguments" in { + JaroWinklerMetric.compare("abc", "xyz").get must beEqualTo(0) + JaroWinklerMetric.compare("123", "456").get must beEqualTo(0) } - "valid arguments" should returns { - "Double indicating distance" in { - JaroWinklerMetric.compare("aa", "a").get should be (0.8500000000000001) - JaroWinklerMetric.compare("a", "aa").get should be (0.8500000000000001) - JaroWinklerMetric.compare("veryveryverylong", "v").get should be (0.71875) - JaroWinklerMetric.compare("v", "veryveryverylong").get should be (0.71875) - JaroWinklerMetric.compare("martha", "marhta").get should be (0.9611111111111111) - JaroWinklerMetric.compare("dwayne", "duane").get should be (0.8400000000000001) - JaroWinklerMetric.compare("dixon", "dicksonx").get should be (0.8133333333333332) - JaroWinklerMetric.compare("abcvwxyz", "cabvwxyz").get should be (0.9583333333333334) - JaroWinklerMetric.compare("jones", "johnson").get should be (0.8323809523809523) - JaroWinklerMetric.compare("henka", "henkan").get should be (0.9666666666666667) - JaroWinklerMetric.compare("fvie", "ten").get should be (0) + "return distance with valid arguments" in { + JaroWinklerMetric.compare("aa", "a").get must beEqualTo(0.8500000000000001) + JaroWinklerMetric.compare("a", "aa").get must beEqualTo(0.8500000000000001) + JaroWinklerMetric.compare("veryveryverylong", "v").get must beEqualTo(0.71875) + JaroWinklerMetric.compare("v", "veryveryverylong").get must beEqualTo(0.71875) + JaroWinklerMetric.compare("martha", "marhta").get must beEqualTo(0.9611111111111111) + JaroWinklerMetric.compare("dwayne", "duane").get must beEqualTo(0.8400000000000001) + JaroWinklerMetric.compare("dixon", "dicksonx").get must beEqualTo(0.8133333333333332) + JaroWinklerMetric.compare("abcvwxyz", "cabvwxyz").get must beEqualTo(0.9583333333333334) + JaroWinklerMetric.compare("jones", "johnson").get must beEqualTo(0.8323809523809523) + JaroWinklerMetric.compare("henka", "henkan").get must beEqualTo(0.9666666666666667) + JaroWinklerMetric.compare("fvie", "ten").get must beEqualTo(0) - JaroWinklerMetric.compare("zac ephron", "zac efron").get should be > - JaroWinklerMetric.compare("zac ephron", "kai ephron").get - JaroWinklerMetric.compare("brittney spears", "britney spears").get should be > - JaroWinklerMetric.compare("brittney spears", "brittney startzman").get - } + JaroWinklerMetric.compare("zac ephron", "zac efron").get must + beGreaterThan(JaroWinklerMetric.compare("zac ephron", "kai ephron").get) + JaroWinklerMetric.compare("brittney spears", "britney spears").get must + beGreaterThan(JaroWinklerMetric.compare("brittney spears", "brittney startzman").get) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala index 8e1538b..111d75f 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala @@ -1,50 +1,37 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - LevenshteinMetric.compare("", "").isDefined should be (false) - LevenshteinMetric.compare("abc", "").isDefined should be (false) - LevenshteinMetric.compare("", "xyz").isDefined should be (false) - } +object LevenshteinMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "LevenshteinMetric compare()" should { + "return None with empty arguments" in { + LevenshteinMetric.compare("", "").isDefined must beFalse + LevenshteinMetric.compare("abc", "").isDefined must beFalse + LevenshteinMetric.compare("", "xyz").isDefined must beFalse } - "equal arguments" should returns { - "0" in { - LevenshteinMetric.compare("abc", "abc").get should be (0) - LevenshteinMetric.compare("123", "123").get should be (0) - } + "return 0 with equal arguments" in { + LevenshteinMetric.compare("abc", "abc").get must beEqualTo(0) + LevenshteinMetric.compare("123", "123").get must beEqualTo(0) } - "unequal arguments" should returns { - "Int indicating distance" in { - LevenshteinMetric.compare("abc", "xyz").get should be (3) - LevenshteinMetric.compare("123", "456").get should be (3) - } + "return distance with unequal arguments" in { + LevenshteinMetric.compare("abc", "xyz").get must beEqualTo(3) + LevenshteinMetric.compare("123", "456").get must beEqualTo(3) } - "valid arguments" should returns { - "Int indicating distance" in { - LevenshteinMetric.compare("abc", "a").get should be (2) - LevenshteinMetric.compare("a", "abc").get should be (2) - LevenshteinMetric.compare("abc", "c").get should be (2) - LevenshteinMetric.compare("c", "abc").get should be (2) - LevenshteinMetric.compare("sitting", "kitten").get should be (3) - LevenshteinMetric.compare("kitten", "sitting").get should be (3) - LevenshteinMetric.compare("cake", "drake").get should be (2) - LevenshteinMetric.compare("drake", "cake").get should be (2) - LevenshteinMetric.compare("saturday", "sunday").get should be (3) - LevenshteinMetric.compare("sunday", "saturday").get should be (3) - LevenshteinMetric.compare("book", "back").get should be (2) - LevenshteinMetric.compare("dog", "fog").get should be (1) - LevenshteinMetric.compare("foq", "fog").get should be (1) - LevenshteinMetric.compare("fvg", "fog").get should be (1) - LevenshteinMetric.compare("encyclopedia", "encyclopediaz").get should be (1) - LevenshteinMetric.compare("encyclopediz", "encyclopediaz").get should be (1) - } + "return distance with valid arguments" in { + LevenshteinMetric.compare("abc", "a").get must beEqualTo(2) + LevenshteinMetric.compare("a", "abc").get must beEqualTo(2) + LevenshteinMetric.compare("abc", "c").get must beEqualTo(2) + LevenshteinMetric.compare("c", "abc").get must beEqualTo(2) + LevenshteinMetric.compare("sitting", "kitten").get must beEqualTo(3) + LevenshteinMetric.compare("kitten", "sitting").get must beEqualTo(3) + LevenshteinMetric.compare("cake", "drake").get must beEqualTo(2) + LevenshteinMetric.compare("drake", "cake").get must beEqualTo(2) + LevenshteinMetric.compare("saturday", "sunday").get must beEqualTo(3) + LevenshteinMetric.compare("sunday", "saturday").get must beEqualTo(3) + LevenshteinMetric.compare("book", "back").get must beEqualTo(2) + LevenshteinMetric.compare("dog", "fog").get must beEqualTo(1) + LevenshteinMetric.compare("foq", "fog").get must beEqualTo(1) + LevenshteinMetric.compare("fvg", "fog").get must beEqualTo(1) + LevenshteinMetric.compare("encyclopedia", "encyclopediaz").get must beEqualTo(1) + LevenshteinMetric.compare("encyclopediz", "encyclopediaz").get must beEqualTo(1) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala index 5e1abb8..501a331 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala @@ -1,60 +1,45 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - NGramMetric(1).compare("", "").isDefined should be (false) - NGramMetric(1).compare("abc", "").isDefined should be (false) - NGramMetric(1).compare("", "xyz").isDefined should be (false) - } +object NGramMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "NGramMetric compare()" should { + "return None with empty arguments" in { + NGramMetric(1).compare("", "").isDefined must beFalse + NGramMetric(1).compare("abc", "").isDefined must beFalse + NGramMetric(1).compare("", "xyz").isDefined must beFalse } - "equal arguments" should returns { - "1" in { - NGramMetric(1).compare("abc", "abc").get should be (1) - NGramMetric(2).compare("abc", "abc").get should be (1) - NGramMetric(3).compare("abc", "abc").get should be (1) - } + "return 1 with equal arguments" in { + NGramMetric(1).compare("abc", "abc").get must beEqualTo(1) + NGramMetric(2).compare("abc", "abc").get must beEqualTo(1) + NGramMetric(3).compare("abc", "abc").get must beEqualTo(1) } - "unequal arguments" should returns { - "0" in { - NGramMetric(1).compare("abc", "xyz").get should be (0) - NGramMetric(2).compare("abc", "xyz").get should be (0) - NGramMetric(3).compare("abc", "xyz").get should be (0) - } + "return 0 with unequal arguments" in { + NGramMetric(1).compare("abc", "xyz").get must beEqualTo(0) + NGramMetric(2).compare("abc", "xyz").get must beEqualTo(0) + NGramMetric(3).compare("abc", "xyz").get must beEqualTo(0) } - "invalid arguments" should returns { - "None" in { - NGramMetric(2).compare("n", "naght").isDefined should be (false) - NGramMetric(2).compare("night", "n").isDefined should be (false) - NGramMetric(3).compare("ni", "naght").isDefined should be (false) - NGramMetric(3).compare("night", "na").isDefined should be (false) - } + "return None with invalid arguments" in { + NGramMetric(2).compare("n", "naght").isDefined must beFalse + NGramMetric(2).compare("night", "n").isDefined must beFalse + NGramMetric(3).compare("ni", "naght").isDefined must beFalse + NGramMetric(3).compare("night", "na").isDefined must beFalse } - "valid arguments" should returns { - "Double indicating distance" in { - NGramMetric(1).compare("night", "nacht").get should be (0.6) - NGramMetric(1).compare("night", "naght").get should be (0.8) - NGramMetric(1).compare("context", "contact").get should be (0.7142857142857143) + "return distance with valid arguments" in { + NGramMetric(1).compare("night", "nacht").get must beEqualTo(0.6) + NGramMetric(1).compare("night", "naght").get must beEqualTo(0.8) + NGramMetric(1).compare("context", "contact").get must beEqualTo(0.7142857142857143) - NGramMetric(2).compare("night", "nacht").get should be (0.25) - NGramMetric(2).compare("night", "naght").get should be (0.5) - NGramMetric(2).compare("context", "contact").get should be (0.5) - NGramMetric(2).compare("contextcontext", "contact").get should be (0.23076923076923078) - NGramMetric(2).compare("context", "contactcontact").get should be (0.23076923076923078) - NGramMetric(2).compare("ht", "nacht").get should be (0.25) - NGramMetric(2).compare("xp", "nacht").get should be (0) - NGramMetric(2).compare("ht", "hththt").get should be (0.2) + NGramMetric(2).compare("night", "nacht").get must beEqualTo(0.25) + NGramMetric(2).compare("night", "naght").get must beEqualTo(0.5) + NGramMetric(2).compare("context", "contact").get must beEqualTo(0.5) + NGramMetric(2).compare("contextcontext", "contact").get must beEqualTo(0.23076923076923078) + NGramMetric(2).compare("context", "contactcontact").get must beEqualTo(0.23076923076923078) + NGramMetric(2).compare("ht", "nacht").get must beEqualTo(0.25) + NGramMetric(2).compare("xp", "nacht").get must beEqualTo(0) + NGramMetric(2).compare("ht", "hththt").get must beEqualTo(0.2) - NGramMetric(3).compare("night", "nacht").get should be (0) - NGramMetric(3).compare("night", "naght").get should be (0.3333333333333333) - NGramMetric(3).compare("context", "contact").get should be (0.4) - } + NGramMetric(3).compare("night", "nacht").get must beEqualTo(0) + NGramMetric(3).compare("night", "naght").get must beEqualTo(0.3333333333333333) + NGramMetric(3).compare("context", "contact").get must beEqualTo(0.4) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala index ec1e7b2..ba50592 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala @@ -1,62 +1,47 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - OverlapMetric(1).compare("", "").isDefined should be (false) - OverlapMetric(1).compare("abc", "").isDefined should be (false) - OverlapMetric(1).compare("", "xyz").isDefined should be (false) - } +object OverlapMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "OverlapMetric compare()" should { + "return None with empty arguments" in { + OverlapMetric(1).compare("", "").isDefined must beFalse + OverlapMetric(1).compare("abc", "").isDefined must beFalse + OverlapMetric(1).compare("", "xyz").isDefined must beFalse } - "equal arguments" should returns { - "1" in { - OverlapMetric(1).compare("abc", "abc").get should be (1) - OverlapMetric(2).compare("abc", "abc").get should be (1) - OverlapMetric(3).compare("abc", "abc").get should be (1) - } + "return 1 with equal arguments" in { + OverlapMetric(1).compare("abc", "abc").get must beEqualTo(1) + OverlapMetric(2).compare("abc", "abc").get must beEqualTo(1) + OverlapMetric(3).compare("abc", "abc").get must beEqualTo(1) } - "unequal arguments" should returns { - "0" in { - OverlapMetric(1).compare("abc", "xyz").get should be (0) - OverlapMetric(2).compare("abc", "xyz").get should be (0) - OverlapMetric(3).compare("abc", "xyz").get should be (0) - } + "return 0 with unequal arguments" in { + OverlapMetric(1).compare("abc", "xyz").get must beEqualTo(0) + OverlapMetric(2).compare("abc", "xyz").get must beEqualTo(0) + OverlapMetric(3).compare("abc", "xyz").get must beEqualTo(0) } - "invalid arguments" should returns { - "None" in { - OverlapMetric(2).compare("n", "naght").isDefined should be (false) - OverlapMetric(2).compare("night", "n").isDefined should be (false) - OverlapMetric(3).compare("ni", "naght").isDefined should be (false) - OverlapMetric(3).compare("night", "na").isDefined should be (false) - } + "return None with invalid arguments" in { + OverlapMetric(2).compare("n", "naght").isDefined must beFalse + OverlapMetric(2).compare("night", "n").isDefined must beFalse + OverlapMetric(3).compare("ni", "naght").isDefined must beFalse + OverlapMetric(3).compare("night", "na").isDefined must beFalse } - "valid arguments" should returns { - "Double indicating distance" in { - OverlapMetric(1).compare("bob", "bobman").get should be (1) - OverlapMetric(1).compare("bob", "manbobman").get should be (1) - OverlapMetric(1).compare("night", "nacht").get should be (0.6) - OverlapMetric(1).compare("night", "naght").get should be (0.8) - OverlapMetric(1).compare("context", "contact").get should be (0.7142857142857143) + "return distance with valid arguments" in { + OverlapMetric(1).compare("bob", "bobman").get must beEqualTo(1) + OverlapMetric(1).compare("bob", "manbobman").get must beEqualTo(1) + OverlapMetric(1).compare("night", "nacht").get must beEqualTo(0.6) + OverlapMetric(1).compare("night", "naght").get must beEqualTo(0.8) + OverlapMetric(1).compare("context", "contact").get must beEqualTo(0.7142857142857143) - OverlapMetric(2).compare("night", "nacht").get should be (0.25) - OverlapMetric(2).compare("night", "naght").get should be (0.5) - OverlapMetric(2).compare("context", "contact").get should be (0.5) - OverlapMetric(2).compare("contextcontext", "contact").get should be (0.5) - OverlapMetric(2).compare("context", "contactcontact").get should be (0.5) - OverlapMetric(2).compare("ht", "nacht").get should be (1) - OverlapMetric(2).compare("xp", "nacht").get should be (0) - OverlapMetric(2).compare("ht", "hththt").get should be (1) + OverlapMetric(2).compare("night", "nacht").get must beEqualTo(0.25) + OverlapMetric(2).compare("night", "naght").get must beEqualTo(0.5) + OverlapMetric(2).compare("context", "contact").get must beEqualTo(0.5) + OverlapMetric(2).compare("contextcontext", "contact").get must beEqualTo(0.5) + OverlapMetric(2).compare("context", "contactcontact").get must beEqualTo(0.5) + OverlapMetric(2).compare("ht", "nacht").get must beEqualTo(1) + OverlapMetric(2).compare("xp", "nacht").get must beEqualTo(0) + OverlapMetric(2).compare("ht", "hththt").get must beEqualTo(1) - OverlapMetric(3).compare("night", "nacht").get should be (0) - OverlapMetric(3).compare("night", "naght").get should be (0.3333333333333333) - OverlapMetric(3).compare("context", "contact").get should be (0.4) - } + OverlapMetric(3).compare("night", "nacht").get must beEqualTo(0) + OverlapMetric(3).compare("night", "naght").get must beEqualTo(0.3333333333333333) + OverlapMetric(3).compare("context", "contact").get must beEqualTo(0.4) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala index 30bbf49..61394ea 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala @@ -1,40 +1,27 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - RatcliffObershelpMetric.compare("", "").isDefined should be (false) - RatcliffObershelpMetric.compare("abc", "").isDefined should be (false) - RatcliffObershelpMetric.compare("", "xyz").isDefined should be (false) - } +object RatcliffObershelpMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "RatcliffObershelpMetric compare()" should { + "return None with empty arguments" in { + RatcliffObershelpMetric.compare("", "").isDefined must beFalse + RatcliffObershelpMetric.compare("abc", "").isDefined must beFalse + RatcliffObershelpMetric.compare("", "xyz").isDefined must beFalse } - "equal arguments" should returns { - "0" in { - RatcliffObershelpMetric.compare("abc", "abc").get should be (1) - RatcliffObershelpMetric.compare("123", "123").get should be (1) - } + "return 0 with equal arguments" in { + RatcliffObershelpMetric.compare("abc", "abc").get must beEqualTo(1) + RatcliffObershelpMetric.compare("123", "123").get must beEqualTo(1) } - "unequal arguments" should returns { - "Double indicating distance" in { - RatcliffObershelpMetric.compare("abc", "xyz").get should be (0) - RatcliffObershelpMetric.compare("123", "456").get should be (0) - } + "return distance with unequal arguments" in { + RatcliffObershelpMetric.compare("abc", "xyz").get must beEqualTo(0) + RatcliffObershelpMetric.compare("123", "456").get must beEqualTo(0) } - "valid arguments" should returns { - "Double indicating distance" in { - RatcliffObershelpMetric.compare("aleksander", "alexandre").get should be (0.7368421052631579) - RatcliffObershelpMetric.compare("alexandre", "aleksander").get should be (0.7368421052631579) - RatcliffObershelpMetric.compare("pennsylvania", "pencilvaneya").get should be (0.6666666666666666) - RatcliffObershelpMetric.compare("pencilvaneya", "pennsylvania").get should be (0.6666666666666666) - RatcliffObershelpMetric.compare("abcefglmn", "abefglmo").get should be (0.8235294117647058) - RatcliffObershelpMetric.compare("abefglmo", "abcefglmn").get should be (0.8235294117647058) - } + "return distance with valid arguments" in { + RatcliffObershelpMetric.compare("aleksander", "alexandre").get must beEqualTo(0.7368421052631579) + RatcliffObershelpMetric.compare("alexandre", "aleksander").get must beEqualTo(0.7368421052631579) + RatcliffObershelpMetric.compare("pennsylvania", "pencilvaneya").get must beEqualTo(0.6666666666666666) + RatcliffObershelpMetric.compare("pencilvaneya", "pennsylvania").get must beEqualTo(0.6666666666666666) + RatcliffObershelpMetric.compare("abcefglmn", "abefglmo").get must beEqualTo(0.8235294117647058) + RatcliffObershelpMetric.compare("abefglmo", "abcefglmn").get must beEqualTo(0.8235294117647058) } } -}} +} diff --git a/core/src/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala index 070458a..53c1254 100755 --- a/core/src/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala @@ -1,48 +1,35 @@ package com.rockymadden.stringmetric.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 { - "compare method" when passed { - "empty arguments" should returns { - "None" in { - WeightedLevenshteinMetric(10, 0.1, 1).compare("", "").isDefined should be (false) - WeightedLevenshteinMetric(10, 0.1, 1).compare("abc", "").isDefined should be (false) - WeightedLevenshteinMetric(10, 0.1, 1).compare("", "xyz").isDefined should be (false) - } +object WeightedLevenshteinMetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "WeightedLevenshteinMetric compare()" should { + "return None with empty arguments" in { + WeightedLevenshteinMetric(10, 0.1, 1).compare("", "").isDefined must beFalse + WeightedLevenshteinMetric(10, 0.1, 1).compare("abc", "").isDefined must beFalse + WeightedLevenshteinMetric(10, 0.1, 1).compare("", "xyz").isDefined must beFalse } - "equal arguments" should returns { - "0" in { - WeightedLevenshteinMetric(10, 0.1, 1).compare("abc", "abc").get should be (0) - WeightedLevenshteinMetric(10, 0.1, 1).compare("123", "123").get should be (0) - } + "return 0 with equal arguments" in { + WeightedLevenshteinMetric(10, 0.1, 1).compare("abc", "abc").get must beEqualTo(0) + WeightedLevenshteinMetric(10, 0.1, 1).compare("123", "123").get must beEqualTo(0) } - "unequal arguments" should returns { - "Double indicating distance" in { - WeightedLevenshteinMetric(10, 0.1, 1).compare("abc", "xyz").get should be (3) - WeightedLevenshteinMetric(10, 0.1, 1).compare("123", "456").get should be (3) - } + "return distance with unequal arguments" in { + WeightedLevenshteinMetric(10, 0.1, 1).compare("abc", "xyz").get must beEqualTo(3) + WeightedLevenshteinMetric(10, 0.1, 1).compare("123", "456").get must beEqualTo(3) } - "valid arguments" should returns { - "Double indicating distance" in { - WeightedLevenshteinMetric(10, 0.1, 1).compare("az", "z").get should be (10) - WeightedLevenshteinMetric(10, 0.1, 1).compare("z", "az").get should be (0.1) - WeightedLevenshteinMetric(10, 0.1, 1).compare("a", "z").get should be (1) - WeightedLevenshteinMetric(10, 0.1, 1).compare("z", "a").get should be (1) - WeightedLevenshteinMetric(10, 0.1, 1).compare("ab", "yz").get should be (2) - WeightedLevenshteinMetric(10, 0.1, 1).compare("yz", "ab").get should be (2) - WeightedLevenshteinMetric(10, 0.1, 1).compare("0", "0123456789").get should be (0.9) - WeightedLevenshteinMetric(10, 0.1, 1).compare("0123456789", "0").get should be (90) - WeightedLevenshteinMetric(10, 0.1, 1).compare("book", "back").get should be (2) - WeightedLevenshteinMetric(10, 0.1, 1).compare("back", "book").get should be (2) - WeightedLevenshteinMetric(10, 0.1, 1).compare("hosp", "hospital").get should be (0.4) - WeightedLevenshteinMetric(10, 0.1, 1).compare("hospital", "hosp").get should be (40) - WeightedLevenshteinMetric(10, 0.1, 1).compare("clmbs blvd", "columbus boulevard").get should be (0.8) - WeightedLevenshteinMetric(10, 0.1, 1).compare("columbus boulevard", "clmbs blvd").get should be (80) - } + "return distance with valid arguments" in { + WeightedLevenshteinMetric(10, 0.1, 1).compare("az", "z").get must beEqualTo(10) + WeightedLevenshteinMetric(10, 0.1, 1).compare("z", "az").get must beEqualTo(0.1) + WeightedLevenshteinMetric(10, 0.1, 1).compare("a", "z").get must beEqualTo(1) + WeightedLevenshteinMetric(10, 0.1, 1).compare("z", "a").get must beEqualTo(1) + WeightedLevenshteinMetric(10, 0.1, 1).compare("ab", "yz").get must beEqualTo(2) + WeightedLevenshteinMetric(10, 0.1, 1).compare("yz", "ab").get must beEqualTo(2) + WeightedLevenshteinMetric(10, 0.1, 1).compare("0", "0123456789").get must beEqualTo(0.9) + WeightedLevenshteinMetric(10, 0.1, 1).compare("0123456789", "0").get must beEqualTo(90) + WeightedLevenshteinMetric(10, 0.1, 1).compare("book", "back").get must beEqualTo(2) + WeightedLevenshteinMetric(10, 0.1, 1).compare("back", "book").get must beEqualTo(2) + WeightedLevenshteinMetric(10, 0.1, 1).compare("hosp", "hospital").get must beEqualTo(0.4) + WeightedLevenshteinMetric(10, 0.1, 1).compare("hospital", "hosp").get must beEqualTo(40) + WeightedLevenshteinMetric(10, 0.1, 1).compare("clmbs blvd", "columbus boulevard").get must beEqualTo(0.8) + WeightedLevenshteinMetric(10, 0.1, 1).compare("columbus boulevard", "clmbs blvd").get must beEqualTo(80) } } -}} +} diff --git a/project/build.scala b/project/build.scala index 8150d08..eeba0ac 100644 --- a/project/build.scala +++ b/project/build.scala @@ -36,10 +36,7 @@ object CoreBuild extends Build { lazy val core: Project = Project("core", file("core"), settings = (root.settings: Seq[sbt.Def.Setting[_]]) ++ Seq( - libraryDependencies ++= Seq( - "junit" % "junit" % "4.11" % "test", - "org.scalatest" %% "scalatest" % "2.0.M5b" % "test" - ), + libraryDependencies ++= Seq("org.specs2" %% "specs2" % "2.3.7" % "test"), name := "stringmetric-core" ) ) |