summaryrefslogtreecommitdiff
path: root/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala
diff options
context:
space:
mode:
Diffstat (limited to 'core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala')
-rwxr-xr-xcore/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala67
1 files changed, 27 insertions, 40 deletions
diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala
index 5ddfc06..6611e27 100755
--- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala
+++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala
@@ -6,70 +6,57 @@ import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
final class DiceSorensenMetricSpec extends ScalaTest {
- import DiceSorensenMetricSpec.Metric
-
"DiceSorensenMetric" should provide {
"compare method" when passed {
"empty arguments" should returns {
"None" in {
- Metric.compare("", "")(1).isDefined should be (false)
- Metric.compare("abc", "")(1).isDefined should be (false)
- Metric.compare("", "xyz")(1).isDefined should be (false)
+ DiceSorensenMetric(1).compare("", "").isDefined should be (false)
+ DiceSorensenMetric(1).compare("abc", "").isDefined should be (false)
+ DiceSorensenMetric(1).compare("", "xyz").isDefined should be (false)
}
}
"equal arguments" should returns {
"1" in {
- Metric.compare("abc", "abc")(1).get should be (1)
- Metric.compare("abc", "abc")(2).get should be (1)
- Metric.compare("abc", "abc")(3).get should be (1)
+ 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)
}
}
"unequal arguments" should returns {
"0" in {
- Metric.compare("abc", "xyz")(1).get should be (0)
- Metric.compare("abc", "xyz")(2).get should be (0)
- Metric.compare("abc", "xyz")(3).get should be (0)
+ 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)
}
}
"invalid arguments" should returns {
"None" in {
- Metric.compare("n", "naght")(2).isDefined should be (false)
- Metric.compare("night", "n")(2).isDefined should be (false)
- Metric.compare("ni", "naght")(3).isDefined should be (false)
- Metric.compare("night", "na")(3).isDefined should be (false)
+ 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)
}
}
"valid arguments" should returns {
"Double indicating distance" in {
- Metric.compare("night", "nacht")(1).get should be (0.6)
- Metric.compare("night", "naght")(1).get should be (0.8)
- Metric.compare("context", "contact")(1).get should be (0.7142857142857143)
+ 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)
- Metric.compare("night", "nacht")(2).get should be (0.25)
- Metric.compare("night", "naght")(2).get should be (0.5)
- Metric.compare("context", "contact")(2).get should be (0.5)
- Metric.compare("contextcontext", "contact")(2).get should be (0.3157894736842105)
- Metric.compare("context", "contactcontact")(2).get should be (0.3157894736842105)
- Metric.compare("ht", "nacht")(2).get should be (0.4)
- Metric.compare("xp", "nacht")(2).get should be (0)
- Metric.compare("ht", "hththt")(2).get should be (0.3333333333333333)
+ 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)
- Metric.compare("night", "nacht")(3).get should be (0)
- Metric.compare("night", "naght")(3).get should be (0.3333333333333333)
- Metric.compare("context", "contact")(3).get should be (0.4)
+ 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 companion object" should provide {
- "pass-through compare method" should returns {
- "same value as class" in {
- DiceSorensenMetric.compare("context", "contact")(3).get should be (0.4)
- }
- }
- }
-}
-
-object DiceSorensenMetricSpec {
- private final val Metric = DiceSorensenMetric()
}