summaryrefslogtreecommitdiff
path: root/core/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test')
-rwxr-xr-xcore/src/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala4
-rw-r--r--core/src/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala (renamed from core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala)9
-rw-r--r--core/src/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala (renamed from core/src/test/scala/com/rockymadden/stringmetric/MetricSpec.scala)13
-rwxr-xr-xcore/src/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala (renamed from core/src/test/scala/com/rockymadden/stringmetric/TokenizeSpec.scala)4
-rw-r--r--core/src/test/scala/com/rockymadden/stringmetric/TransformSpec.scala72
-rw-r--r--core/src/test/scala/com/rockymadden/stringmetric/transformSpec.scala159
6 files changed, 208 insertions, 53 deletions
diff --git a/core/src/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala
index 43e5d80..0145aea 100755
--- a/core/src/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala
+++ b/core/src/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala
@@ -1,8 +1,8 @@
package com.rockymadden.stringmetric
-object AlphabetSpec extends org.specs2.mutable.SpecificationWithJUnit {
- import Alphabet.{Alpha, Vowel}
+import com.rockymadden.stringmetric.Alphabet._
+object AlphabetSpec extends org.specs2.mutable.SpecificationWithJUnit {
"AlphabetSet isSuperset()" should {
"return false with non-alphabet argument" in {
Alpha isSuperset '0' must beFalse
diff --git a/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala
index 15110dd..6366685 100644
--- a/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala
+++ b/core/src/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala
@@ -1,10 +1,9 @@
package com.rockymadden.stringmetric
-object AlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit {
- import phonetic._
- import Algorithm._
- import Transform._
+import com.rockymadden.stringmetric.phonetic._
+import com.rockymadden.stringmetric.transform._
+object StringAlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit {
"StringAlgorithm convenience methods" should {
"pass through" in {
StringAlgorithm.computeWithMetaphone("testone").get must
@@ -35,7 +34,7 @@ object AlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit {
"StringAlgorithmDecorator withTransform()" should {
"transform" in {
- (MetaphoneAlgorithm withTransform StringTransform.filterAlpha).compute("abc123").get must
+ (MetaphoneAlgorithm withTransform filterAlpha).compute("abc123").get must
beEqualTo(MetaphoneAlgorithm.compute("abc").get)
}
}
diff --git a/core/src/test/scala/com/rockymadden/stringmetric/MetricSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala
index a72889e..fbdc536 100644
--- a/core/src/test/scala/com/rockymadden/stringmetric/MetricSpec.scala
+++ b/core/src/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala
@@ -1,11 +1,10 @@
package com.rockymadden.stringmetric
-object MetricSpec extends org.specs2.mutable.SpecificationWithJUnit {
- import phonetic._
- import similarity._
- import Metric._
- import Transform._
+import com.rockymadden.stringmetric.phonetic._
+import com.rockymadden.stringmetric.similarity._
+import com.rockymadden.stringmetric.transform._
+object StringMetricSpec extends org.specs2.mutable.SpecificationWithJUnit {
"StringMetric convenience methods" should {
"pass through" in {
StringMetric.compareWithDiceSorensen(1)("testone", "testtwo").get must
@@ -54,9 +53,9 @@ object MetricSpec extends org.specs2.mutable.SpecificationWithJUnit {
"StringMetricDecorator withTransform()" should {
"transform" in {
- (MetaphoneMetric withTransform StringTransform.filterAlpha).compare("abc123", "abc456").get must
+ (MetaphoneMetric withTransform filterAlpha).compare("abc123", "abc456").get must
beEqualTo(true)
- (DiceSorensenMetric(1) withTransform StringTransform.filterAlpha).compare("abc123", "abc456").get must
+ (DiceSorensenMetric(1) withTransform filterAlpha).compare("abc123", "abc456").get must
beEqualTo(1.0)
}
}
diff --git a/core/src/test/scala/com/rockymadden/stringmetric/TokenizeSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala
index c133c66..0a994b7 100755
--- a/core/src/test/scala/com/rockymadden/stringmetric/TokenizeSpec.scala
+++ b/core/src/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala
@@ -1,8 +1,6 @@
package com.rockymadden.stringmetric
-object TokenizeSpec extends org.specs2.mutable.SpecificationWithJUnit {
- import Tokenize._
-
+object StringTokenizerSpec extends org.specs2.mutable.SpecificationWithJUnit {
"NGramTokenizer tokenize()" should {
"return None with empty argument" in {
NGramTokenizer(1).tokenize("").isDefined must beEqualTo(false)
diff --git a/core/src/test/scala/com/rockymadden/stringmetric/TransformSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/TransformSpec.scala
index c9c5029..01fa3a3 100644
--- a/core/src/test/scala/com/rockymadden/stringmetric/TransformSpec.scala
+++ b/core/src/test/scala/com/rockymadden/stringmetric/TransformSpec.scala
@@ -1,19 +1,19 @@
package com.rockymadden.stringmetric
-object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit {
- import Transform._
+import com.rockymadden.stringmetric.transform._
- "StringTransform filterAlpha()" should {
+object transformSpec extends org.specs2.mutable.SpecificationWithJUnit {
+ "filterAlpha()" should {
"return transformed" in {
- StringTransform.filterAlpha(
+ filterAlpha(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo("aBc".toCharArray)
}
}
- "StringTransform filterNotAlpha()" should {
+ "filterNotAlpha()" should {
"return transformed" in {
- StringTransform.filterNotAlpha(
+ filterNotAlpha(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo(
("123" + 0x250.toChar).toCharArray
@@ -21,17 +21,17 @@ object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit {
}
}
- "StringTransform filterAlphaNumeric()" should {
+ "filterAlphaNumeric()" should {
"return transformed" in {
- StringTransform.filterAlphaNumeric(
+ filterAlphaNumeric(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo("aBc123".toCharArray)
}
}
- "StringTransform filterNotAlphaNumeric()" should {
+ "filterNotAlphaNumeric()" should {
"return transformed" in {
- StringTransform.filterNotAlphaNumeric(
+ filterNotAlphaNumeric(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo(
("" + 0x250.toChar).toCharArray
@@ -39,17 +39,17 @@ object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit {
}
}
- "StringTransform filterAscii()" should {
+ "filterAscii()" should {
"return transformed" in {
- StringTransform.filterAscii(
+ filterAscii(
("aBc" + 0x80.toChar).toCharArray
) must beEqualTo("aBc".toCharArray)
}
}
- "StringTransform filterNotAscii()" should {
+ "filterNotAscii()" should {
"return transformed" in {
- StringTransform.filterNotAscii(
+ filterNotAscii(
("aBc" + 0x100.toChar).toCharArray
) must beEqualTo(
("" + 0x100.toChar).toCharArray
@@ -57,17 +57,17 @@ object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit {
}
}
- "StringTransform filterExtendedAscii()" should {
+ "filterExtendedAscii()" should {
"return transformed" in {
- StringTransform.filterExtendedAscii(
+ filterExtendedAscii(
("aBc" + 0x100.toChar).toCharArray
) must beEqualTo("aBc".toCharArray)
}
}
- "StringTransform filterNotExtendedAscii()" should {
+ "filterNotExtendedAscii()" should {
"return transformed" in {
- StringTransform.filterNotExtendedAscii(
+ filterNotExtendedAscii(
("aBc" + 0x250.toChar).toCharArray
) must beEqualTo(
("" + 0x250.toChar).toCharArray
@@ -75,17 +75,17 @@ object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit {
}
}
- "StringTransform filterLatin()" should {
+ "filterLatin()" should {
"return transformed" in {
- StringTransform.filterLatin(
+ filterLatin(
("aBc" + 0x250.toChar).toCharArray
) must beEqualTo("aBc".toCharArray)
}
}
- "StringTransform filterNotLatin()" should {
+ "filterNotLatin()" should {
"return transformed" in {
- StringTransform.filterNotLatin(
+ filterNotLatin(
("aBc" + 0x300.toChar).toCharArray
) must beEqualTo(
("" + 0x300.toChar).toCharArray
@@ -93,17 +93,17 @@ object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit {
}
}
- "StringTransform filterLowerCase()" should {
+ "filterLowerCase()" should {
"return transformed" in {
- StringTransform.filterLowerCase(
+ filterLowerCase(
"aBc123" + 0x250.toChar
) must beEqualTo("ac".toCharArray)
}
}
- "StringTransform filterNotLowerCase()" should {
+ "filterNotLowerCase()" should {
"return transformed" in {
- StringTransform.filterNotLowerCase(
+ filterNotLowerCase(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo(
("B123" + 0x250.toChar).toCharArray
@@ -111,17 +111,17 @@ object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit {
}
}
- "StringTransform filterNumeric()" should {
+ "filterNumeric()" should {
"return transformed" in {
- StringTransform.filterNumeric(
+ filterNumeric(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo("123".toCharArray)
}
}
- "StringTransform filterNotNumeric()" should {
+ "filterNotNumeric()" should {
"return transformed" in {
- StringTransform.filterNotNumeric(
+ filterNotNumeric(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo(
("aBc" + 0x250.toChar).toCharArray
@@ -129,17 +129,17 @@ object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit {
}
}
- "StringTransform filterUpperCase()" should {
+ "filterUpperCase()" should {
"return transformed" in {
- StringTransform.filterUpperCase(
+ filterUpperCase(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo("B".toCharArray)
}
}
- "StringTransform filterNotUpperCase()" should {
+ "filterNotUpperCase()" should {
"return transformed" in {
- StringTransform.filterNotUpperCase(
+ filterNotUpperCase(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo(
("ac123" + 0x250.toChar).toCharArray
@@ -147,9 +147,9 @@ object TransformSpec extends org.specs2.mutable.SpecificationWithJUnit {
}
}
- "StringTransform ignoreAlphaCase()" should {
+ "ignoreAlphaCase()" should {
"return transformed" in {
- StringTransform.ignoreAlphaCase(
+ ignoreAlphaCase(
("aBc123" + 0x250.toChar).toCharArray
) must beEqualTo(
("abc123" + 0x250.toChar).toCharArray
diff --git a/core/src/test/scala/com/rockymadden/stringmetric/transformSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/transformSpec.scala
new file mode 100644
index 0000000..01fa3a3
--- /dev/null
+++ b/core/src/test/scala/com/rockymadden/stringmetric/transformSpec.scala
@@ -0,0 +1,159 @@
+package com.rockymadden.stringmetric
+
+import com.rockymadden.stringmetric.transform._
+
+object transformSpec extends org.specs2.mutable.SpecificationWithJUnit {
+ "filterAlpha()" should {
+ "return transformed" in {
+ filterAlpha(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo("aBc".toCharArray)
+ }
+ }
+
+ "filterNotAlpha()" should {
+ "return transformed" in {
+ filterNotAlpha(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo(
+ ("123" + 0x250.toChar).toCharArray
+ )
+ }
+ }
+
+ "filterAlphaNumeric()" should {
+ "return transformed" in {
+ filterAlphaNumeric(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo("aBc123".toCharArray)
+ }
+ }
+
+ "filterNotAlphaNumeric()" should {
+ "return transformed" in {
+ filterNotAlphaNumeric(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo(
+ ("" + 0x250.toChar).toCharArray
+ )
+ }
+ }
+
+ "filterAscii()" should {
+ "return transformed" in {
+ filterAscii(
+ ("aBc" + 0x80.toChar).toCharArray
+ ) must beEqualTo("aBc".toCharArray)
+ }
+ }
+
+ "filterNotAscii()" should {
+ "return transformed" in {
+ filterNotAscii(
+ ("aBc" + 0x100.toChar).toCharArray
+ ) must beEqualTo(
+ ("" + 0x100.toChar).toCharArray
+ )
+ }
+ }
+
+ "filterExtendedAscii()" should {
+ "return transformed" in {
+ filterExtendedAscii(
+ ("aBc" + 0x100.toChar).toCharArray
+ ) must beEqualTo("aBc".toCharArray)
+ }
+ }
+
+ "filterNotExtendedAscii()" should {
+ "return transformed" in {
+ filterNotExtendedAscii(
+ ("aBc" + 0x250.toChar).toCharArray
+ ) must beEqualTo(
+ ("" + 0x250.toChar).toCharArray
+ )
+ }
+ }
+
+ "filterLatin()" should {
+ "return transformed" in {
+ filterLatin(
+ ("aBc" + 0x250.toChar).toCharArray
+ ) must beEqualTo("aBc".toCharArray)
+ }
+ }
+
+ "filterNotLatin()" should {
+ "return transformed" in {
+ filterNotLatin(
+ ("aBc" + 0x300.toChar).toCharArray
+ ) must beEqualTo(
+ ("" + 0x300.toChar).toCharArray
+ )
+ }
+ }
+
+ "filterLowerCase()" should {
+ "return transformed" in {
+ filterLowerCase(
+ "aBc123" + 0x250.toChar
+ ) must beEqualTo("ac".toCharArray)
+ }
+ }
+
+ "filterNotLowerCase()" should {
+ "return transformed" in {
+ filterNotLowerCase(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo(
+ ("B123" + 0x250.toChar).toCharArray
+ )
+ }
+ }
+
+ "filterNumeric()" should {
+ "return transformed" in {
+ filterNumeric(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo("123".toCharArray)
+ }
+ }
+
+ "filterNotNumeric()" should {
+ "return transformed" in {
+ filterNotNumeric(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo(
+ ("aBc" + 0x250.toChar).toCharArray
+ )
+ }
+ }
+
+ "filterUpperCase()" should {
+ "return transformed" in {
+ filterUpperCase(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo("B".toCharArray)
+ }
+ }
+
+ "filterNotUpperCase()" should {
+ "return transformed" in {
+ filterNotUpperCase(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo(
+ ("ac123" + 0x250.toChar).toCharArray
+ )
+ }
+ }
+
+ "ignoreAlphaCase()" should {
+ "return transformed" in {
+ ignoreAlphaCase(
+ ("aBc123" + 0x250.toChar).toCharArray
+ ) must beEqualTo(
+ ("abc123" + 0x250.toChar).toCharArray
+ )
+ }
+ }
+}