diff options
author | Rocky Madden <git@rockymadden.com> | 2013-03-15 12:32:04 -0600 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2013-03-15 12:32:04 -0600 |
commit | 7083b01e4aaf0bb3263c8ecfe92e5f66bca13f63 (patch) | |
tree | ae472b0b8d1789aad8f8fcec64518ac0638291e9 /core/source | |
parent | 351883a732263bb77a88d805eb9780505ec89023 (diff) | |
download | stringmetric-7083b01e4aaf0bb3263c8ecfe92e5f66bca13f63.tar.gz stringmetric-7083b01e4aaf0bb3263c8ecfe92e5f66bca13f63.tar.bz2 stringmetric-7083b01e4aaf0bb3263c8ecfe92e5f66bca13f63.zip |
Added unit tests of convenience objects.
Diffstat (limited to 'core/source')
4 files changed, 237 insertions, 0 deletions
diff --git a/core/source/test/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithmSpec.scala new file mode 100755 index 0000000..eb09a25 --- /dev/null +++ b/core/source/test/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithmSpec.scala @@ -0,0 +1,23 @@ +package com.rockymadden.stringmetric + +import com.rockymadden.stringmetric.similarity._ +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class ConfigurableStringAlgorithmSpec extends ScalaTest { + "StringAlgorithm standalone object" should provide { + "compute method, type, and companion object pass-throughs" in { + val nGram: ConfigurableStringAlgorithm.NGram = ConfigurableStringAlgorithm.NGram() + + nGram.compute("testone")(1).get should + equal (ConfigurableStringAlgorithm.computeWithNGram("testone")(1).get) + nGram.compute("testone".toCharArray)(1).get should + equal (ConfigurableStringAlgorithm.computeWithNGram("testone".toCharArray)(1).get) + nGram.compute("testone".toCharArray)(1).get should + equal (NGramAlgorithm.compute("testone".toCharArray)(1).get) + } + } +} + + diff --git a/core/source/test/scala/com/rockymadden/stringmetric/ConfigurableStringMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/ConfigurableStringMetricSpec.scala new file mode 100755 index 0000000..c548db3 --- /dev/null +++ b/core/source/test/scala/com/rockymadden/stringmetric/ConfigurableStringMetricSpec.scala @@ -0,0 +1,59 @@ +package com.rockymadden.stringmetric + +import com.rockymadden.stringmetric.similarity._ +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class ConfigurableStringMetricSpec extends ScalaTest { + "StringMetric standalone object" should provide { + "compare method, type, and companion object pass-throughs" in { + val diceSorensen: ConfigurableStringMetric.DiceSorensen = ConfigurableStringMetric.DiceSorensen() + + diceSorensen.compare("testone", "testtwo")(1).get should + equal (ConfigurableStringMetric.compareWithDiceSorensen("testone", "testtwo")(1).get) + diceSorensen.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should + equal (ConfigurableStringMetric.compareWithDiceSorensen("testone".toCharArray, "testtwo".toCharArray)(1).get) + diceSorensen.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should + equal (DiceSorensenMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1).get) + + val jaccard: ConfigurableStringMetric.Jaccard = ConfigurableStringMetric.Jaccard() + + jaccard.compare("testone", "testtwo")(1).get should + equal (ConfigurableStringMetric.compareWithJaccard("testone", "testtwo")(1).get) + jaccard.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should + equal (ConfigurableStringMetric.compareWithJaccard("testone".toCharArray, "testtwo".toCharArray)(1).get) + jaccard.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should + equal (JaccardMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1).get) + + val nGram: ConfigurableStringMetric.NGram = ConfigurableStringMetric.NGram() + + nGram.compare("testone", "testtwo")(1).get should + equal (ConfigurableStringMetric.compareWithNGram("testone", "testtwo")(1).get) + nGram.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should + equal (ConfigurableStringMetric.compareWithNGram("testone".toCharArray, "testtwo".toCharArray)(1).get) + nGram.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should + equal (NGramMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1).get) + + val overlap: ConfigurableStringMetric.Overlap = ConfigurableStringMetric.Overlap() + + overlap.compare("testone", "testtwo")(1).get should + equal (ConfigurableStringMetric.compareWithOverlap("testone", "testtwo")(1).get) + overlap.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should + equal (ConfigurableStringMetric.compareWithOverlap("testone".toCharArray, "testtwo".toCharArray)(1).get) + overlap.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should + equal (OverlapMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1).get) + + val weightedLevenshtein: ConfigurableStringMetric.WeightedLevenshtein = ConfigurableStringMetric.WeightedLevenshtein() + + weightedLevenshtein.compare("testone", "testtwo")(1, 2, 3).get should + equal (ConfigurableStringMetric.compareWithWeightedLevenshtein("testone", "testtwo")(1, 2, 3).get) + weightedLevenshtein.compare("testone".toCharArray, "testtwo".toCharArray)(1, 2, 3).get should + equal (ConfigurableStringMetric.compareWithWeightedLevenshtein("testone".toCharArray, "testtwo".toCharArray)(1, 2, 3).get) + weightedLevenshtein.compare("testone".toCharArray, "testtwo".toCharArray)(1, 2, 3).get should + equal (WeightedLevenshteinMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1, 2, 3).get) + } + } +} + + diff --git a/core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala new file mode 100755 index 0000000..7ce0c24 --- /dev/null +++ b/core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala @@ -0,0 +1,59 @@ +package com.rockymadden.stringmetric + +import com.rockymadden.stringmetric.phonetic._ +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class StringAlgorithmSpec extends ScalaTest { + "StringAlgorithm standalone object" should provide { + "compute method, type, and companion object pass-throughs" in { + val metaphone: StringAlgorithm.Metaphone = StringAlgorithm.Metaphone() + + metaphone.compute("testone").get should + equal (StringAlgorithm.computeWithMetaphone("testone").get) + metaphone.compute("testone".toCharArray).get should + equal (StringAlgorithm.computeWithMetaphone("testone".toCharArray).get) + metaphone.compute("testone".toCharArray).get should + equal (MetaphoneAlgorithm.compute("testone".toCharArray).get) + + val nysiis: StringAlgorithm.Nysiis = StringAlgorithm.Nysiis() + + nysiis.compute("testone").get should + equal (StringAlgorithm.computeWithNysiis("testone").get) + nysiis.compute("testone".toCharArray).get should + equal (StringAlgorithm.computeWithNysiis("testone".toCharArray).get) + nysiis.compute("testone".toCharArray).get should + equal (NysiisAlgorithm.compute("testone".toCharArray).get) + + val refinedNysiis: StringAlgorithm.RefinedNysiis = StringAlgorithm.RefinedNysiis() + + refinedNysiis.compute("testone").get should + equal (StringAlgorithm.computeWithRefinedNysiis("testone").get) + refinedNysiis.compute("testone".toCharArray).get should + equal (StringAlgorithm.computeWithRefinedNysiis("testone".toCharArray).get) + refinedNysiis.compute("testone".toCharArray).get should + equal (RefinedNysiisAlgorithm.compute("testone".toCharArray).get) + + val refinedSoundex: StringAlgorithm.RefinedSoundex = StringAlgorithm.RefinedSoundex() + + refinedSoundex.compute("testone").get should + equal (StringAlgorithm.computeWithRefinedSoundex("testone").get) + refinedSoundex.compute("testone".toCharArray).get should + equal (StringAlgorithm.computeWithRefinedSoundex("testone".toCharArray).get) + refinedSoundex.compute("testone".toCharArray).get should + equal (RefinedSoundexAlgorithm.compute("testone".toCharArray).get) + + val soundex: StringAlgorithm.Soundex = StringAlgorithm.Soundex() + + soundex.compute("testone").get should + equal (StringAlgorithm.computeWithSoundex("testone").get) + soundex.compute("testone".toCharArray).get should + equal (StringAlgorithm.computeWithSoundex("testone".toCharArray).get) + soundex.compute("testone".toCharArray).get should + equal (SoundexAlgorithm.compute("testone".toCharArray).get) + } + } +} + + diff --git a/core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala new file mode 100755 index 0000000..2fdd925 --- /dev/null +++ b/core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala @@ -0,0 +1,96 @@ +package com.rockymadden.stringmetric + +import com.rockymadden.stringmetric.phonetic._ +import com.rockymadden.stringmetric.similarity._ +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class StringMetricSpec extends ScalaTest { + "StringMetric standalone object" should provide { + "compare method, type, and companion object pass-throughs" in { + val hamming: StringMetric.Hamming = StringMetric.Hamming() + + hamming.compare("testone", "testtwo").get should + equal (StringMetric.compareWithHamming("testone", "testtwo").get) + hamming.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (StringMetric.compareWithHamming("testone".toCharArray, "testtwo".toCharArray).get) + hamming.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (HammingMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + + val jaro: StringMetric.Jaro = StringMetric.Jaro() + + jaro.compare("testone", "testtwo").get should + equal (StringMetric.compareWithJaro("testone", "testtwo").get) + jaro.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (StringMetric.compareWithJaro("testone".toCharArray, "testtwo".toCharArray).get) + jaro.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (JaroMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + + val jaroWinkler: StringMetric.JaroWinkler = StringMetric.JaroWinkler() + + jaroWinkler.compare("testone", "testtwo").get should + equal (StringMetric.compareWithJaroWinkler("testone", "testtwo").get) + jaroWinkler.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (StringMetric.compareWithJaroWinkler("testone".toCharArray, "testtwo".toCharArray).get) + jaroWinkler.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (JaroWinklerMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + + val levenshtein: StringMetric.Levenshtein = StringMetric.Levenshtein() + + levenshtein.compare("testone", "testtwo").get should + equal (StringMetric.compareWithLevenshtein("testone", "testtwo").get) + levenshtein.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (StringMetric.compareWithLevenshtein("testone".toCharArray, "testtwo".toCharArray).get) + levenshtein.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (LevenshteinMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + + val metaphone: StringMetric.Metaphone = StringMetric.Metaphone() + + metaphone.compare("testone", "testtwo").get should + equal (StringMetric.compareWithMetaphone("testone", "testtwo").get) + metaphone.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (StringMetric.compareWithMetaphone("testone".toCharArray, "testtwo".toCharArray).get) + metaphone.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (MetaphoneMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + + val nysiis: StringMetric.Nysiis = StringMetric.Nysiis() + + nysiis.compare("testone", "testtwo").get should + equal (StringMetric.compareWithNysiis("testone", "testtwo").get) + nysiis.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (StringMetric.compareWithNysiis("testone".toCharArray, "testtwo".toCharArray).get) + nysiis.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (NysiisMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + + val refinedNysiis: StringMetric.RefinedNysiis = StringMetric.RefinedNysiis() + + refinedNysiis.compare("testone", "testtwo").get should + equal (StringMetric.compareWithRefinedNysiis("testone", "testtwo").get) + refinedNysiis.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (StringMetric.compareWithRefinedNysiis("testone".toCharArray, "testtwo".toCharArray).get) + refinedNysiis.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (RefinedNysiisMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + + val refinedSoundex: StringMetric.RefinedSoundex = StringMetric.RefinedSoundex() + + refinedSoundex.compare("testone", "testtwo").get should + equal (StringMetric.compareWithRefinedSoundex("testone", "testtwo").get) + refinedSoundex.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (StringMetric.compareWithRefinedSoundex("testone".toCharArray, "testtwo".toCharArray).get) + refinedSoundex.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (RefinedSoundexMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + + val soundex: StringMetric.Soundex = StringMetric.Soundex() + + soundex.compare("testone", "testtwo").get should + equal (StringMetric.compareWithSoundex("testone", "testtwo").get) + soundex.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (StringMetric.compareWithSoundex("testone".toCharArray, "testtwo".toCharArray).get) + soundex.compare("testone".toCharArray, "testtwo".toCharArray).get should + equal (SoundexMetric.compare("testone".toCharArray, "testtwo".toCharArray).get) + } + } +} + + |