diff options
author | Rocky Madden <git@rockymadden.com> | 2012-11-28 09:44:47 -0700 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2012-11-28 09:44:47 -0700 |
commit | 870bbdcf048fb32dad7df14fdd172f12a04994c4 (patch) | |
tree | 93853e335ab9a3bda9ca53d13bc5454108e97ead | |
parent | d4a54178a055a03732d7b90d5a034184868f4b29 (diff) | |
download | stringmetric-870bbdcf048fb32dad7df14fdd172f12a04994c4.tar.gz stringmetric-870bbdcf048fb32dad7df14fdd172f12a04994c4.tar.bz2 stringmetric-870bbdcf048fb32dad7df14fdd172f12a04994c4.zip |
Added phonetic algorithm unit tests.
2 files changed, 218 insertions, 3 deletions
diff --git a/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala index 7d7d76b..5044dd5 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala @@ -20,8 +20,116 @@ final class RefinedSoundexAlgorithmSpec extends ScalaTest { } "phonetic argument" should returns { "Some" in { - RefinedSoundexAlgorithm.compute("x123").get should equal ("x5") + // a + RefinedSoundexAlgorithm.compute("a").get should equal ("a0") + RefinedSoundexAlgorithm.compute("aa").get should equal ("a0") + // b + RefinedSoundexAlgorithm.compute("b").get should equal ("b1") + RefinedSoundexAlgorithm.compute("bb").get should equal ("b1") + + // c + RefinedSoundexAlgorithm.compute("c").get should equal ("c3") + RefinedSoundexAlgorithm.compute("cc").get should equal ("c3") + + // d + RefinedSoundexAlgorithm.compute("d").get should equal ("d6") + RefinedSoundexAlgorithm.compute("dd").get should equal ("d6") + + // e + RefinedSoundexAlgorithm.compute("e").get should equal ("e0") + RefinedSoundexAlgorithm.compute("ee").get should equal ("e0") + + // f + RefinedSoundexAlgorithm.compute("f").get should equal ("f2") + RefinedSoundexAlgorithm.compute("ff").get should equal ("f2") + + // g + RefinedSoundexAlgorithm.compute("g").get should equal ("g4") + RefinedSoundexAlgorithm.compute("gg").get should equal ("g4") + + // h + RefinedSoundexAlgorithm.compute("h").get should equal ("h0") + RefinedSoundexAlgorithm.compute("hh").get should equal ("h0") + + // i + RefinedSoundexAlgorithm.compute("i").get should equal ("i0") + RefinedSoundexAlgorithm.compute("ii").get should equal ("i0") + + // j + RefinedSoundexAlgorithm.compute("j").get should equal ("j4") + RefinedSoundexAlgorithm.compute("jj").get should equal ("j4") + + // k + RefinedSoundexAlgorithm.compute("k").get should equal ("k3") + RefinedSoundexAlgorithm.compute("kk").get should equal ("k3") + + // l + RefinedSoundexAlgorithm.compute("l").get should equal ("l7") + RefinedSoundexAlgorithm.compute("ll").get should equal ("l7") + + // m + RefinedSoundexAlgorithm.compute("m").get should equal ("m8") + RefinedSoundexAlgorithm.compute("mm").get should equal ("m8") + + // n + RefinedSoundexAlgorithm.compute("n").get should equal ("n8") + RefinedSoundexAlgorithm.compute("nn").get should equal ("n8") + + // o + RefinedSoundexAlgorithm.compute("o").get should equal ("o0") + RefinedSoundexAlgorithm.compute("oo").get should equal ("o0") + + // p + RefinedSoundexAlgorithm.compute("p").get should equal ("p1") + RefinedSoundexAlgorithm.compute("pp").get should equal ("p1") + + // q + RefinedSoundexAlgorithm.compute("q").get should equal ("q5") + RefinedSoundexAlgorithm.compute("qq").get should equal ("q5") + + // r + RefinedSoundexAlgorithm.compute("r").get should equal ("r9") + RefinedSoundexAlgorithm.compute("rr").get should equal ("r9") + + // s + RefinedSoundexAlgorithm.compute("s").get should equal ("s3") + RefinedSoundexAlgorithm.compute("ss").get should equal ("s3") + + // t + RefinedSoundexAlgorithm.compute("t").get should equal ("t6") + RefinedSoundexAlgorithm.compute("tt").get should equal ("t6") + + // u + RefinedSoundexAlgorithm.compute("u").get should equal ("u0") + RefinedSoundexAlgorithm.compute("uu").get should equal ("u0") + + // v + RefinedSoundexAlgorithm.compute("v").get should equal ("v2") + RefinedSoundexAlgorithm.compute("vv").get should equal ("v2") + + // w + RefinedSoundexAlgorithm.compute("w").get should equal ("w0") + RefinedSoundexAlgorithm.compute("ww").get should equal ("w0") + + // x + RefinedSoundexAlgorithm.compute("x").get should equal ("x5") + RefinedSoundexAlgorithm.compute("xx").get should equal ("x5") + + // y + RefinedSoundexAlgorithm.compute("y").get should equal ("y0") + RefinedSoundexAlgorithm.compute("yy").get should equal ("y0") + + // z + RefinedSoundexAlgorithm.compute("z").get should equal ("z5") + RefinedSoundexAlgorithm.compute("zz").get should equal ("z5") + + // Starting with letter then numbers. + RefinedSoundexAlgorithm.compute("x123456").get should equal ("x5") + RefinedSoundexAlgorithm.compute("a123456").get should equal ("a0") + RefinedSoundexAlgorithm.compute("f123456").get should equal ("f2") + + // Miscellaneous. RefinedSoundexAlgorithm.compute("braz").get should equal ("b1905") RefinedSoundexAlgorithm.compute("broz").get should equal ("b1905") RefinedSoundexAlgorithm.compute("caren").get should equal ("c30908") diff --git a/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithmSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithmSpec.scala index 8a8c21b..aa97e45 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithmSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithmSpec.scala @@ -20,11 +20,118 @@ final class SoundexAlgorithmSpec extends ScalaTest { } "phonetic argument" should returns { "Some" in { - SoundexAlgorithm.compute("x123").get should equal ("x000") + // a + SoundexAlgorithm.compute("a").get should equal ("a000") + SoundexAlgorithm.compute("aa").get should equal ("a000") + // b + SoundexAlgorithm.compute("b").get should equal ("b000") + SoundexAlgorithm.compute("bb").get should equal ("b000") + + // c + SoundexAlgorithm.compute("c").get should equal ("c000") + SoundexAlgorithm.compute("cc").get should equal ("c000") + + // d + SoundexAlgorithm.compute("d").get should equal ("d000") + SoundexAlgorithm.compute("dd").get should equal ("d000") + + // e + SoundexAlgorithm.compute("e").get should equal ("e000") + SoundexAlgorithm.compute("ee").get should equal ("e000") + + // f + SoundexAlgorithm.compute("f").get should equal ("f000") + SoundexAlgorithm.compute("ff").get should equal ("f000") + + // g + SoundexAlgorithm.compute("g").get should equal ("g000") + SoundexAlgorithm.compute("gg").get should equal ("g000") + + // h + SoundexAlgorithm.compute("h").get should equal ("h000") + SoundexAlgorithm.compute("hh").get should equal ("h000") + + // i + SoundexAlgorithm.compute("i").get should equal ("i000") + SoundexAlgorithm.compute("ii").get should equal ("i000") + + // j + SoundexAlgorithm.compute("j").get should equal ("j000") + SoundexAlgorithm.compute("jj").get should equal ("j000") + + // k + SoundexAlgorithm.compute("k").get should equal ("k000") + SoundexAlgorithm.compute("kk").get should equal ("k000") + + // l + SoundexAlgorithm.compute("l").get should equal ("l000") + SoundexAlgorithm.compute("ll").get should equal ("l000") + + // m + SoundexAlgorithm.compute("m").get should equal ("m000") + SoundexAlgorithm.compute("mm").get should equal ("m000") + + // n + SoundexAlgorithm.compute("n").get should equal ("n000") + SoundexAlgorithm.compute("nn").get should equal ("n000") + + // o + SoundexAlgorithm.compute("o").get should equal ("o000") + SoundexAlgorithm.compute("oo").get should equal ("o000") + + // p + SoundexAlgorithm.compute("p").get should equal ("p000") + SoundexAlgorithm.compute("pp").get should equal ("p000") + + // q + SoundexAlgorithm.compute("q").get should equal ("q000") + SoundexAlgorithm.compute("qq").get should equal ("q000") + + // r + SoundexAlgorithm.compute("r").get should equal ("r000") + SoundexAlgorithm.compute("rr").get should equal ("r000") + + // s + SoundexAlgorithm.compute("s").get should equal ("s000") + SoundexAlgorithm.compute("ss").get should equal ("s000") + + // t + SoundexAlgorithm.compute("t").get should equal ("t000") + SoundexAlgorithm.compute("tt").get should equal ("t000") + + // u + SoundexAlgorithm.compute("u").get should equal ("u000") + SoundexAlgorithm.compute("uu").get should equal ("u000") + + // v + SoundexAlgorithm.compute("v").get should equal ("v000") + SoundexAlgorithm.compute("vv").get should equal ("v000") + + // w + SoundexAlgorithm.compute("w").get should equal ("w000") + SoundexAlgorithm.compute("ww").get should equal ("w000") + + // x + SoundexAlgorithm.compute("x").get should equal ("x000") + SoundexAlgorithm.compute("xx").get should equal ("x000") + + // y + SoundexAlgorithm.compute("y").get should equal ("y000") + SoundexAlgorithm.compute("yy").get should equal ("y000") + + // z + SoundexAlgorithm.compute("z").get should equal ("z000") + SoundexAlgorithm.compute("zz").get should equal ("z000") + + // Starting with letter then numbers. + SoundexAlgorithm.compute("x123456").get should equal ("x000") + SoundexAlgorithm.compute("a123456").get should equal ("a000") + SoundexAlgorithm.compute("f123456").get should equal ("f000") + + // Miscellaneous. SoundexAlgorithm.compute("abc").get should equal ("a120") SoundexAlgorithm.compute("xyz").get should equal ("x200") - SoundexAlgorithm.compute("robert").get should equal ("r163") SoundexAlgorithm.compute("rupert").get should equal ("r163") SoundexAlgorithm.compute("rubin").get should equal ("r150") |