diff options
author | Rocky Madden <git@rockymadden.com> | 2012-10-20 15:47:47 -0600 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2012-10-20 15:47:47 -0600 |
commit | e5888541fc1c76d73c159a1380fc33e3c3d9e2ce (patch) | |
tree | 288f1a4fb18b298cd88a5d2628163d60f5986a8e /core | |
parent | c91fe035e4427f4ca071c55455e19b011a33a1d5 (diff) | |
download | stringmetric-e5888541fc1c76d73c159a1380fc33e3c3d9e2ce.tar.gz stringmetric-e5888541fc1c76d73c159a1380fc33e3c3d9e2ce.tar.bz2 stringmetric-e5888541fc1c76d73c159a1380fc33e3c3d9e2ce.zip |
Unit test clean up.
Diffstat (limited to 'core')
4 files changed, 63 insertions, 50 deletions
diff --git a/core/source/test/scala/org/hashtree/stringmetric/distance/HammingMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/distance/HammingMetricSpec.scala index 21608c2..ff92fc3 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/distance/HammingMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/distance/HammingMetricSpec.scala @@ -8,14 +8,25 @@ import org.scalatest.junit.JUnitRunner final class HammingMetricSpec extends ScalaTest { "HammingMetric" should provide { "compare method" when passed { - "valid arguments" should returns { - "Int indicating distance" in { + "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) - + } + } + "equal arguments" should returns { + "0" in { HammingMetric.compare("abc", "abc").get should be (0) + } + } + "unequal arguments" should returns { + "Int indicating distance" in { HammingMetric.compare("abc", "xyz").get should be (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) diff --git a/core/source/test/scala/org/hashtree/stringmetric/distance/JaroMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/distance/JaroMetricSpec.scala index f07a4e9..1b74c53 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/distance/JaroMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/distance/JaroMetricSpec.scala @@ -8,21 +8,30 @@ import org.scalatest.junit.JUnitRunner final class JaroMetricSpec extends ScalaTest { "JaroMetric" should provide { "compare method" when passed { - "valid arguments" should returns { - "Float indicating distance" in { - JaroMetric.compare("abc", "abc").get should be (1.0f) - JaroMetric.compare("abc", "xyz").get should be (0.0f) + "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) - JaroMetric.compare("", "").isDefined should be (false) + } + } + "equal arguments" should returns { + "1" in { JaroMetric.compare("a", "a").get should be (1.0f) - + JaroMetric.compare("abc", "abc").get should be (1.0f) + } + } + "unequal arguments" should returns { + "0" in { + JaroMetric.compare("abc", "xyz").get should be (0.0f) + } + } + "valid arguments" should returns { + "Float indicating distance" in { JaroMetric.compare("aa", "a").get should be (0.8333333f) JaroMetric.compare("a", "aa").get should be (0.8333333f) - JaroMetric.compare("veryveryverylong", "v").get should be (0.6875f) JaroMetric.compare("v", "veryveryverylong").get should be (0.6875f) - JaroMetric.compare("martha", "marhta").get should be (0.9444444f) JaroMetric.compare("dwayne", "duane").get should be (0.82222223f) JaroMetric.compare("dixon", "dicksonx").get should be (0.76666665f) @@ -35,19 +44,6 @@ final class JaroMetricSpec extends ScalaTest { 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("m a r t h a", "m a r h t a").get should be (0.9444444f) - JaroMetric.compare("d w a y n e", "d u a n e").get should be (0.82222223f) - JaroMetric.compare("d i x o n", "d i c k s o n x").get should be (0.76666665f) - JaroMetric.compare("a b c v w x y z", "c a b v w x y z").get should be (0.9583333f) - JaroMetric.compare("j o n e s", "j o h n s o n").get should be (0.79047614f) - JaroMetric.compare("h e n k a", "h e n k a n").get should be (0.9444444f) - JaroMetric.compare("f v i e", "t e n").get should be (0.0f) - - JaroMetric.compare("z a c e p h r o n", "z a c e f r o n").get should be > - JaroMetric.compare("z a c e p h r o n", "k a i e p h r o n").get - JaroMetric.compare("b r i t t n e y s p e a r s", "b r i t n e y s p e a r s").get should be > - JaroMetric.compare("b r i t t n e y s p e a r s", "b r i t t n e y s t a r t z m a n").get } } } diff --git a/core/source/test/scala/org/hashtree/stringmetric/distance/JaroWinklerMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/distance/JaroWinklerMetricSpec.scala index 0e52b4f..93d78c7 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/distance/JaroWinklerMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/distance/JaroWinklerMetricSpec.scala @@ -8,21 +8,30 @@ import org.scalatest.junit.JUnitRunner final class JaroWinklerMetricSpec extends ScalaTest { "JaroWinklerMetric" should provide { "compare method" when passed { - "valid arguments" should returns { - "Float indicating distance" in { - JaroWinklerMetric.compare("abc", "abc").get should be (1.0f) - JaroWinklerMetric.compare("abc", "xyz").get should be (0.0f) + "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) - JaroWinklerMetric.compare("", "").isDefined should be (false) + } + } + "equal arguments" should returns { + "1" in { JaroWinklerMetric.compare("a", "a").get should be (1.0f) - + JaroWinklerMetric.compare("abc", "abc").get should be (1.0f) + } + } + "unequal arguments" should returns { + "0" in { + JaroWinklerMetric.compare("abc", "xyz").get should be (0.0f) + } + } + "valid arguments" should returns { + "Float indicating distance" in { JaroWinklerMetric.compare("aa", "a").get should be (0.84999996f) JaroWinklerMetric.compare("a", "aa").get should be (0.84999996f) - JaroWinklerMetric.compare("veryveryverylong", "v").get should be (0.71875f) JaroWinklerMetric.compare("v", "veryveryverylong").get should be (0.71875f) - JaroWinklerMetric.compare("martha", "marhta").get should be (0.96111107f) JaroWinklerMetric.compare("dwayne", "duane").get should be (0.84000003f) JaroWinklerMetric.compare("dixon", "dicksonx").get should be (0.81333333f) @@ -35,19 +44,6 @@ final class JaroWinklerMetricSpec extends ScalaTest { 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("m a r t h a", "m a r h t a").get should be (0.96111107f) - JaroWinklerMetric.compare("d w a y n e", "d u a n e").get should be (0.84000003f) - JaroWinklerMetric.compare("d i x o n", "d i c k s o n x").get should be (0.81333333f) - JaroWinklerMetric.compare("a b c v w x y z", "c a b v w x y z").get should be (0.9583333f) - JaroWinklerMetric.compare("j o n e s", "j o h n s o n").get should be (0.8323809f) - JaroWinklerMetric.compare("h e n k a", "h e n k a n").get should be (0.96666664f) - JaroWinklerMetric.compare("f v i e", "t e n").get should be (0.0f) - - JaroWinklerMetric.compare("z a c e p h r o n", "z a c e f r o n").get should be > - JaroWinklerMetric.compare("z a c e p h r o n", "k a i e p h r o n").get - JaroWinklerMetric.compare("b r i t t n e y s p e a r s", "b r i t n e y s p e a r s").get should be > - JaroWinklerMetric.compare("b r i t t n e y s p e a r s", "b r i t t n e y s t a r t z m a n").get } } } diff --git a/core/source/test/scala/org/hashtree/stringmetric/distance/LevenshteinMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/distance/LevenshteinMetricSpec.scala index 07e3a94..e1e3ec3 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/distance/LevenshteinMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/distance/LevenshteinMetricSpec.scala @@ -8,19 +8,29 @@ import org.scalatest.junit.JUnitRunner final class LevenshteinMetricSpec extends ScalaTest { "LevenshteinMetric" should provide { "compare method" when passed { - "valid arguments" should returns { - "Int indicating distance" in { + "empty arguments" should returns { + "None" in { LevenshteinMetric.compare("", "").isDefined should be (false) - + } + } + "equal arguments" should returns { + "0" in { + LevenshteinMetric.compare("abc", "abc").get should be (0) + } + } + "unequal arguments" should returns { + "Int indicating distance" in { LevenshteinMetric.compare("abc", "").get should be (3) LevenshteinMetric.compare("", "xyz").get should be (3) - LevenshteinMetric.compare("abc", "abc").get should be (0) LevenshteinMetric.compare("abc", "xyz").get should be (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("kitten", "sitting").get should be (3) LevenshteinMetric.compare("drake", "cake").get should be (2) } |