summaryrefslogtreecommitdiff
path: root/core/source/test/scala/com/rockymadden/stringmetric/phonetic/AlphabetSpec.scala
blob: 8074ca8334b5a82f52a096051e1ce26702b5412b (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package com.rockymadden.stringmetric.phonetic

import com.rockymadden.stringmetric.ScalaTest
import com.rockymadden.stringmetric.phonetic.Alphabet.{ Alpha, Vowel }
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
final class AlphabetSpec extends ScalaTest {
	"Alphabet" should provide {
		"an overloaded isSuperset method which accepts Char" when passed {
			"non-alphabet argument" should returns {
				"false" in {
					Alpha isSuperset '0' should be (false)
				}
			}
			"alphabet argument" should returns {
				"true" in {
					Alpha isSuperset 'a' should be (true)
					Alpha isSuperset 'A' should be (true)
				}
			}
			"non-vowel argument" should returns {
				"false" in {
					Vowel isSuperset 'y' should be (false)
				}
			}
			"vowel argument" should returns {
				"true" in {
					Vowel isSuperset 'a' should be (true)
					Vowel isSuperset 'A' should be (true)
				}
			}
		}
		"an overloaded isSuperset method which accepts Array[Char]" when passed {
			"empty argument" should returns {
				"false" in {
					Alpha isSuperset Array.empty[Char] should be (false)
				}
			}
			"non-alphabet argument" should returns {
				"false" in {
					Alpha isSuperset "hi!".toCharArray should be (false)
					Alpha isSuperset "helloworld!".toCharArray should be (false)
				}
			}
			"alphabet argument" should returns {
				"true" in {
					Alpha isSuperset "hi".toCharArray should be (true)
					Alpha isSuperset "helloworld".toCharArray should be (true)
					Alpha isSuperset "HI".toCharArray should be (true)
					Alpha isSuperset "HELLOWORLD".toCharArray should be (true)
				}
			}
			"non-vowel argument" should returns {
				"false" in {
					Vowel isSuperset "y".toCharArray should be (false)
				}
			}
			"vowel argument" should returns {
				"true" in {
					Vowel isSuperset "a".toCharArray should be (true)
					Vowel isSuperset "A".toCharArray should be (true)
				}
			}
		}
		"an overloaded isSuperset method which accepts String" when passed {
			"empty argument" should returns {
				"false" in {
					Alpha isSuperset "" should be (false)
				}
			}
			"non-alphabet argument" should returns {
				"false" in {
					Alpha isSuperset "helloworld!" should be (false)
				}
			}
			"alphabet argument" should returns {
				"true" in {
					Alpha isSuperset "helloworld" should be (true)
					Alpha isSuperset "HELLOWORLD" should be (true)
				}
			}
			"non-vowel argument" should returns {
				"false" in {
					Vowel isSuperset "y" should be (false)
				}
			}
			"vowel argument" should returns {
				"true" in {
					Vowel isSuperset "a" should be (true)
					Vowel isSuperset "A" should be (true)
				}
			}
		}
		"an overloaded startsWith method which accepts Array[Char]" when passed {
			"empty argument" should returns {
				"false" in {
					Alpha startsWith Array.empty[Char] should be (false)
				}
			}
			"non-alphabet argument" should returns {
				"false" in {
					Alpha startsWith "1abc".toCharArray should be (false)
				}
			}
			"alphabet argument" should returns {
				"true" in {
					Alpha startsWith "abc".toCharArray should be (true)
				}
			}
		}
		"an overloaded startsWith method which accepts Char" when passed {
			"empty argument" should returns {
				"false" in {
					Alpha startsWith '0' should be (false)
				}
			}
			"non-alphabet argument" should returns {
				"false" in {
					Alpha startsWith '1' should be (false)
				}
			}
			"alphabet argument" should returns {
				"true" in {
					Alpha startsWith 'a' should be (true)
				}
			}
		}
		"an overloaded startsWith method which accepts String" when passed {
			"empty argument" should returns {
				"false" in {
					Alpha startsWith "" should be (false)
				}
			}
			"non-alphabet argument" should returns {
				"false" in {
					Alpha startsWith "1abc" should be (false)
				}
			}
			"alphabet argument" should returns {
				"true" in {
					Alpha startsWith "abc" should be (true)
				}
			}
		}
	}
}