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 /core/src/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala | |
parent | fa6545a0f828112adf61d97edb58b24dd8bc3693 (diff) | |
download | stringmetric-a6e907a0532d50f3fda44109d0c0fe1a15b40134.tar.gz stringmetric-a6e907a0532d50f3fda44109d0c0fe1a15b40134.tar.bz2 stringmetric-a6e907a0532d50f3fda44109d0c0fe1a15b40134.zip |
Moved from scalatest to specs2.
Diffstat (limited to 'core/src/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala')
-rwxr-xr-x | core/src/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala | 89 |
1 files changed, 37 insertions, 52 deletions
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) } } -}} +} |