summaryrefslogtreecommitdiff
path: root/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberOnlyFilterSpec.scala
blob: 7998e398296d337dde63a5f0ca5ae432109232b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.rockymadden.stringmetric.filter

import com.rockymadden.stringmetric.ScalaTest
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
final class AsciiLetterNumberOnlyFilterSpec extends ScalaTest {
	import AsciiLetterNumberOnlyFilterSpec.Filter

	"AsciiLetterNumberOnlyFilter" should provide {
		"overloaded filter method" when passed {
			"String with mixed characters" should returns {
				"String with non-letters and non-numbers removed" in {
					Filter.filter("!@#$%^&*()abc") should equal ("abc")
					Filter.filter("!@#$%^&*()abc123") should equal ("abc123")
					Filter.filter("abc123!@#$%^&*()") should equal ("abc123")
					Filter.filter("!@#$%abc123^&*()") should equal ("abc123")
				}
			}
			"character array with mixed characters" should returns {
				"character array with non-letters and non-numbers removed" in {
					Filter.filter("!@#$%^&*()abc".toCharArray) should equal ("abc".toCharArray)
					Filter.filter("!@#$%^&*()abc123".toCharArray) should equal ("abc123".toCharArray)
					Filter.filter("abc123!@#$%^&*()".toCharArray) should equal ("abc123".toCharArray)
					Filter.filter("!@#$%abc123^&*()".toCharArray) should equal ("abc123".toCharArray)
				}
			}
		}
	}
}

object AsciiLetterNumberOnlyFilterSpec {
	private final val Filter = new StringFilterDelegate with AsciiLetterNumberOnlyFilter
}