summaryrefslogtreecommitdiff
path: root/core/source/test/scala
diff options
context:
space:
mode:
authorRocky Madden <git@rockymadden.com>2012-10-08 22:29:42 -0600
committerRocky Madden <git@rockymadden.com>2012-10-08 22:29:42 -0600
commitf380762362860d432d27d9861d817be393f19da6 (patch)
tree59da9b12cc59452a1b2a774a54f508be36e73d42 /core/source/test/scala
parent2b6d745e54ed5a4c9f3253f9c97188861aef4452 (diff)
downloadstringmetric-f380762362860d432d27d9861d817be393f19da6.tar.gz
stringmetric-f380762362860d432d27d9861d817be393f19da6.tar.bz2
stringmetric-f380762362860d432d27d9861d817be393f19da6.zip
Created cleaners to allow implementors to determine the amount of cleaning performed on inputs prior to metric computations, if desired. Applied implicitly to metric compare methods in second curry. Previous behavior of ignoring case and spacing held in tact, while allowing for further definition if needed via arguments.
Diffstat (limited to 'core/source/test/scala')
-rwxr-xr-xcore/source/test/scala/org/hashtree/stringmetric/CaseStringCleanerSpec.scala36
-rwxr-xr-xcore/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala1
-rwxr-xr-xcore/source/test/scala/org/hashtree/stringmetric/SpaceStringCleanerSpec.scala32
-rwxr-xr-xcore/source/test/scala/org/hashtree/stringmetric/StringCleanerDelegateSpec.scala24
4 files changed, 93 insertions, 0 deletions
diff --git a/core/source/test/scala/org/hashtree/stringmetric/CaseStringCleanerSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/CaseStringCleanerSpec.scala
new file mode 100755
index 0000000..a628700
--- /dev/null
+++ b/core/source/test/scala/org/hashtree/stringmetric/CaseStringCleanerSpec.scala
@@ -0,0 +1,36 @@
+package org.hashtree.stringmetric
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class CaseStringCleanerSpec extends ScalaTest {
+ private final val Cleaner = new StringCleanerDelegate with CaseStringCleaner
+
+ "CaseStringCleaner" should provide {
+ "overloaded clean method" when passed {
+ "String with mixed case" should returns {
+ "String with the same case" in {
+ Cleaner.clean("HelloWorld") should (equal ("helloworld") or equal ("HELLOWORLD"))
+ Cleaner.clean("Hello World") should (equal ("hello world") or equal ("HELLO WORLD"))
+ Cleaner.clean("H e l l o W o r l d") should
+ (equal ("h e l l o w o r l d") or equal ("H E L L O W O R L D"))
+ Cleaner.clean("H e l l o W o r l d") should
+ (equal ("h e l l o w o r l d") or equal ("H E L L O W O R L D"))
+ }
+ }
+ "character array with mixed case" should returns {
+ "character array with the same case" in {
+ Cleaner.clean("HelloWorld".toCharArray) should
+ (equal ("helloworld".toCharArray) or equal ("HELLOWORLD".toCharArray))
+ Cleaner.clean("Hello World".toCharArray) should
+ (equal ("hello world".toCharArray) or equal ("HELLO WORLD".toCharArray))
+ Cleaner.clean("H e l l o W o r l d".toCharArray) should
+ (equal ("h e l l o w o r l d".toCharArray) or equal ("H E L L O W O R L D".toCharArray))
+ Cleaner.clean("H e l l o W o r l d".toCharArray) should
+ (equal ("h e l l o w o r l d".toCharArray) or equal ("H E L L O W O R L D".toCharArray))
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala
index 5d164e2..a7059a3 100755
--- a/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala
+++ b/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala
@@ -36,6 +36,7 @@ final class JaroMetricSpec extends ScalaTest {
JaroMetric.compare("brittney spears", "brittney startzman")
JaroMetric.compare("m a r t h a", "m a r h t a") should be (0.9444444f)
+
JaroMetric.compare("d w a y n e", "d u a n e") should be (0.82222223f)
JaroMetric.compare("d i x o n", "d i c k s o n x") should be (0.76666665f)
JaroMetric.compare("a b c v w x y z", "c a b v w x y z") should be (0.9583333f)
diff --git a/core/source/test/scala/org/hashtree/stringmetric/SpaceStringCleanerSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/SpaceStringCleanerSpec.scala
new file mode 100755
index 0000000..f58a4df
--- /dev/null
+++ b/core/source/test/scala/org/hashtree/stringmetric/SpaceStringCleanerSpec.scala
@@ -0,0 +1,32 @@
+package org.hashtree.stringmetric
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class SpaceStringCleanerSpec extends ScalaTest {
+ private final val Cleaner = new StringCleanerDelegate with SpaceStringCleaner
+
+ "SpaceStringCleaner" should provide {
+ "overloaded clean method" when passed {
+ "String with spaces" should returns {
+ "String with spaces removed" in {
+ Cleaner.clean("HelloWorld") should equal ("HelloWorld")
+ Cleaner.clean(" HelloWorld ") should equal ("HelloWorld")
+ Cleaner.clean("Hello World") should equal ("HelloWorld")
+ Cleaner.clean("H e l l o W o r l d") should equal ("HelloWorld")
+ Cleaner.clean("H e l l o W o r l d") should equal ("HelloWorld")
+ }
+ }
+ "character array with spaces" should returns {
+ "character array with spaces removed" in {
+ Cleaner.clean("HelloWorld".toCharArray) should equal ("HelloWorld".toCharArray)
+ Cleaner.clean(" HelloWorld ".toCharArray) should equal ("HelloWorld".toCharArray)
+ Cleaner.clean("Hello World".toCharArray) should equal ("HelloWorld".toCharArray)
+ Cleaner.clean("H e l l o W o r l d".toCharArray) should equal ("HelloWorld".toCharArray)
+ Cleaner.clean("H e l l o W o r l d".toCharArray) should equal ("HelloWorld".toCharArray)
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/core/source/test/scala/org/hashtree/stringmetric/StringCleanerDelegateSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/StringCleanerDelegateSpec.scala
new file mode 100755
index 0000000..5016500
--- /dev/null
+++ b/core/source/test/scala/org/hashtree/stringmetric/StringCleanerDelegateSpec.scala
@@ -0,0 +1,24 @@
+package org.hashtree.stringmetric
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class StringCleanerDelegateSpec extends ScalaTest {
+ private final val Cleaner = new StringCleanerDelegate
+
+ "StringCleanerDelegate" should provide {
+ "overloaded clean method" when passed {
+ "String" should returns {
+ "the same String" in {
+ Cleaner.clean("Hello World") should equal ("Hello World")
+ }
+ }
+ "character array" should returns {
+ "the same character array" in {
+ Cleaner.clean("Hello World".toCharArray) should equal ("Hello World".toCharArray)
+ }
+ }
+ }
+ }
+} \ No newline at end of file