diff options
Diffstat (limited to 'core/src/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala')
-rw-r--r-- | core/src/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/core/src/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala new file mode 100644 index 0000000..6366685 --- /dev/null +++ b/core/src/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala @@ -0,0 +1,41 @@ +package com.rockymadden.stringmetric + +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 + beEqualTo(MetaphoneAlgorithm.compute("testone".toCharArray).get) + StringAlgorithm.computeWithNysiis("testone").get must + beEqualTo(NysiisAlgorithm.compute("testone".toCharArray).get) + StringAlgorithm.computeWithRefinedNysiis("testone").get must + beEqualTo(RefinedNysiisAlgorithm.compute("testone".toCharArray).get) + StringAlgorithm.computeWithRefinedSoundex("testone").get must + beEqualTo(RefinedSoundexAlgorithm.compute("testone".toCharArray).get) + StringAlgorithm.computeWithSoundex("testone").get must + beEqualTo(SoundexAlgorithm.compute("testone".toCharArray).get) + } + } + + "StringAlgorithmDecorator withMemoization()" should { + "memoize" in { + val memo = MetaphoneAlgorithm withMemoization + + (0 until 1000000) foreach { i => + memo.compute("abc123") + memo.compute("abc456") + } + + true must beTrue + } + } + + "StringAlgorithmDecorator withTransform()" should { + "transform" in { + (MetaphoneAlgorithm withTransform filterAlpha).compute("abc123").get must + beEqualTo(MetaphoneAlgorithm.compute("abc").get) + } + } +} |