@@ -6,24 +6,135 @@ import java.util.ArrayList
6
6
import java.util.HashMap
7
7
import org.spek.*
8
8
import org.humanizer.jvm.humanize
9
+ import org.humanizer.jvm.LetterCasing
10
+ import org.humanizer.jvm.checkAllCaps
9
11
10
12
public class PascalCaseHumanizerTests (): Spek() {
11
13
{
12
14
13
- val data = listOf (
14
- " ThisIsATest" to " This Is A Test" ,
15
- " ThisIsAnotherTest" to " This Is Another Test"
16
- )
15
+ var data = listOf (
16
+ " PascalCaseInputStringIsTurnedIntoSentence" to" Pascal case input string is turned into sentence" ,
17
+ " WhenIUseAnInputAHere" to" When I use an input a here" ,
18
+ " 10IsInTheBegining" to" 10 is in the begining" ,
19
+ " NumberIsAtTheEnd100" to" Number is at the end 100" ,
20
+ " XIsFirstWordInTheSentence" to" X is first word in the sentence" )
17
21
18
- givenData(data) {
19
- val (input, expected) = it
20
- on(" calling humanize" , {
21
- val actual = input.humanize()
22
- it(" should become ${it.component2()} " , {
23
- shouldEqual(expected, actual)
22
+ givenData(data) {
23
+ val (input ,expected) = it
24
+ on(" calling humanize on $input " ,{
25
+ val actual = input.humanize()
26
+ it(" should become ${it.component2()} " ,{
27
+ shouldEqual(expected, actual)
28
+ })
24
29
})
25
- })
26
- }
30
+ }
31
+
32
+ data = listOf (
33
+ " Underscored_input_string_is_turned_into_sentence" to" Underscored input string is turned into sentence" ,
34
+ " Underscored_input_String_is_turned_INTO_sentence" to" Underscored input String is turned INTO sentence" )
35
+
36
+ givenData(data) {
37
+ val (input ,expected) = it
38
+ on(" calling humanize on $input " ,{
39
+ val actual = input.humanize()
40
+ it(" should become ${it.component2()} " ,{
41
+ shouldEqual(expected, actual)
42
+ })
43
+ })
44
+ }
45
+
46
+ data = listOf (
47
+ " HTML" to" HTML" ,
48
+ " TheHTMLLanguage" to" The HTML language" ,
49
+ " HTMLIsTheLanguage" to" HTML is the language" ,
50
+ " TheLanguageIsHTML" to" The language is HTML" ,
51
+ " HTML5" to" HTML 5" ,
52
+ " 1HTML" to" 1 HTML" )
53
+
54
+ givenData(data) {
55
+ val (input ,expected) = it
56
+ on(" calling humanize on $input " ,{
57
+ val actual = input.humanize()
58
+ it(" should become ${it.component2()} " ,{
59
+ shouldEqual(expected, actual)
60
+ })
61
+ })
62
+ }
63
+
64
+ data = listOf (
65
+ " CanReturnTitleCase" to" Can Return Title Case" ,
66
+ " Can_return_title_Case" to" Can Return Title Case" ,
67
+ " Title_humanization_Honors_ALLCAPS" to" Title Humanization Honors ALLCAPS" )
68
+
69
+ givenData(data) {
70
+ val (input ,expected) = it
71
+ on(" calling humanize on $input " ,{
72
+ val actual = input.humanize(LetterCasing .Title )
73
+ it(" should become ${it.component2()} " ,{
74
+ shouldEqual(expected, actual)
75
+ })
76
+ })
77
+ }
78
+
79
+ data = listOf (
80
+ " CanReturnLowerCase" to" can return lower case" ,
81
+ " Can_Return_Lower_Case" to" can return lower case" ,
82
+ " LOWERCASE" to" lowercase" )
83
+
84
+ givenData(data) {
85
+ val (input ,expected) = it
86
+ on(" calling humanize on $input " ,{
87
+ val actual = input.humanize(LetterCasing .LowerCase )
88
+ it(" should become ${it.component2()} " ,{
89
+ shouldEqual(expected, actual)
90
+ })
91
+ })
92
+ }
93
+
94
+ data = listOf (
95
+ " CanReturnSentenceCase" to" Can return sentence case" ,
96
+ " Can_Return_Sentence_Case" to" Can Return Sentence Case" ,
97
+ " " to" " )
98
+
99
+ givenData(data) {
100
+ val (input ,expected) = it
101
+ on(" calling humanize on $input " ,{
102
+ val actual = input.humanize(LetterCasing .Sentence )
103
+ it(" should become ${it.component2()} " ,{
104
+ shouldEqual(expected, actual)
105
+ })
106
+ })
107
+ }
108
+
109
+ data = listOf (
110
+ " CanHumanizeIntoUpperCase" to" CAN HUMANIZE INTO UPPER CASE" ,
111
+ " Can_Humanize_into_Upper_case" to" CAN HUMANIZE INTO UPPER CASE" )
112
+
113
+ givenData(data) {
114
+ val (input ,expected) = it
115
+ on(" calling humanize on $input " ,{
116
+ val actual = input.humanize(LetterCasing .AllCaps )
117
+ it(" should become ${it.component2()} " ,{
118
+ shouldEqual(expected, actual)
119
+ })
120
+ })
121
+ }
122
+
123
+ given(" A word in all caps" ){
124
+ on(" calling checkAllCaps" , {
125
+ it(" should be true" , {
126
+ shouldEqual(true , " HTML" .checkAllCaps())
127
+ })
128
+ })
129
+ }
130
+
131
+ given(" A word in all lowercase" ){
132
+ on(" calling checkAllCaps" , {
133
+ it(" should be false" , {
134
+ shouldEqual(false , " html" .checkAllCaps())
135
+ })
136
+ })
137
+ }
27
138
28
139
}}
29
140
0 commit comments