diff options
author | Rocky Madden <git@rockymadden.com> | 2013-12-31 11:57:10 -0700 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2013-12-31 11:57:10 -0700 |
commit | abd84f7895979a3209422b59296e92f2118b062d (patch) | |
tree | 890bb505b56a75d503a33f5752f4fcb3534ce78c /core/source | |
parent | 09ee8d1438c84e45b3cccf9a205b5234da68afcf (diff) | |
download | stringmetric-abd84f7895979a3209422b59296e92f2118b062d.tar.gz stringmetric-abd84f7895979a3209422b59296e92f2118b062d.tar.bz2 stringmetric-abd84f7895979a3209422b59296e92f2118b062d.zip |
Created ignoreAlphaCase transform.
Diffstat (limited to 'core/source')
-rw-r--r-- | core/source/main/scala/com/rockymadden/stringmetric/Transform.scala | 2 | ||||
-rw-r--r-- | core/source/test/scala/com/rockymadden/stringmetric/TransformSpec.scala | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/core/source/main/scala/com/rockymadden/stringmetric/Transform.scala b/core/source/main/scala/com/rockymadden/stringmetric/Transform.scala index 390c4f2..c2cdace 100644 --- a/core/source/main/scala/com/rockymadden/stringmetric/Transform.scala +++ b/core/source/main/scala/com/rockymadden/stringmetric/Transform.scala @@ -65,5 +65,7 @@ object Transform { val filterUpperCase: StringTransform = (ca) => filter(ca, c => UpperCase.contains(c.toInt)) val filterNotUpperCase: StringTransform = (ca) => filterNot(ca, c => UpperCase.contains(c.toInt)) + + val ignoreAlphaCase: StringTransform = (ca) => ca.map(c => if (c >= 65 && c <= 90) (c + 32).toChar else c) } } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/TransformSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/TransformSpec.scala index 5b93cfa..2349a6a 100644 --- a/core/source/test/scala/com/rockymadden/stringmetric/TransformSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/TransformSpec.scala @@ -167,4 +167,15 @@ final class TransformSpec extends ScalaTest { "StringTransform" should provide { } } } + "ignoreAlphaCase()" when passed { + "String" should returns { + "transformed String" in { + StringTransform.ignoreAlphaCase( + ("aBc123" + 0x250.toChar).toCharArray + ) should equal ( + ("abc123" + 0x250.toChar).toCharArray + ) + } + } + } }} |