diff options
Diffstat (limited to 'core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala')
-rw-r--r-- | core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala b/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala index b95046d..15110dd 100644 --- a/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala +++ b/core/src/test/scala/com/rockymadden/stringmetric/AlgorithmSpec.scala @@ -1,43 +1,42 @@ package com.rockymadden.stringmetric -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class AlgorithmSpec extends ScalaTest { +object AlgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { import phonetic._ import Algorithm._ import Transform._ - "StringAlgorithm" should provide { - "compute method and companion object pass through" in { - StringAlgorithm.computeWithMetaphone("testone").get should - equal (MetaphoneAlgorithm.compute("testone".toCharArray).get) - StringAlgorithm.computeWithNysiis("testone").get should - equal (NysiisAlgorithm.compute("testone".toCharArray).get) - StringAlgorithm.computeWithRefinedNysiis("testone").get should - equal (RefinedNysiisAlgorithm.compute("testone".toCharArray).get) - StringAlgorithm.computeWithRefinedSoundex("testone").get should - equal (RefinedSoundexAlgorithm.compute("testone".toCharArray).get) - StringAlgorithm.computeWithSoundex("testone").get should - equal (SoundexAlgorithm.compute("testone".toCharArray).get) + "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" should provide { - "withMemoization()" in { + "StringAlgorithmDecorator withMemoization()" should { + "memoize" in { val memo = MetaphoneAlgorithm withMemoization (0 until 1000000) foreach { i => memo.compute("abc123") memo.compute("abc456") } + + true must beTrue } + } - "withTransform()" in { - (MetaphoneAlgorithm withTransform StringTransform.filterAlpha).compute("abc123").get should - equal (MetaphoneAlgorithm.compute("abc").get) + "StringAlgorithmDecorator withTransform()" should { + "transform" in { + (MetaphoneAlgorithm withTransform StringTransform.filterAlpha).compute("abc123").get must + beEqualTo(MetaphoneAlgorithm.compute("abc").get) } } } - |