-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstring_test.go
186 lines (159 loc) · 5.19 KB
/
string_test.go
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package assert
import "testing"
func TestThatStringIsEqualToHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Alice").IsEqualTo("Alice").IsEqualTo("Alice")
mockT.HasNoErrors()
}
func TestThatStringIsEqualToHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Alice").IsEqualTo("Bob").IsEqualTo("Charlie")
mockT.HasErrorMessages(
"Expected <Bob>, but was <Alice>.",
"Expected <Charlie>, but was <Alice>.",
)
}
func TestThatStringIsNotEqualToHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Alice").IsNotEqualTo("Bob").IsNotEqualTo("Bob")
mockT.HasNoErrors()
}
func TestThatStringIsNotEqualToHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Alice").IsNotEqualTo("Alice")
mockT.HasErrorMessages(
"Expected string not equal to <Alice>, but was equal.",
)
}
func TestThatStringIsEmptyHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("").IsEmpty()
mockT.HasNoErrors()
}
func TestThatStringIsEmptyHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").IsEmpty()
mockT.HasErrorMessages(
"Expected string to be empty, but was <Marta>.",
)
}
func TestThatStringIsNotEmptyHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").IsNotEmpty()
mockT.HasNoErrors()
}
func TestThatStringIsNotEmptyHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("").IsNotEmpty()
mockT.HasErrorMessages(
"Expected string to not be empty, but was.",
)
}
func TestThatStringIsInSliceHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").IsInSlice([]string{"Marta"})
mockT.HasNoErrors()
}
func TestThatStringIsInSliceHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").IsInSlice([]string{"Michal", "Macy"})
mockT.HasErrorMessages(
"Expected string to be in slice <[Michal Macy]>, but wasn't.",
)
}
func TestThatStringIsNotInSliceHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").IsNotInSlice([]string{"Michal"})
mockT.HasNoErrors()
}
func TestThatStringIsNotInSliceHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").IsNotInSlice([]string{"Marta"})
mockT.HasErrorMessages(
"Expected string to not be in slice <[Marta]>, but was.",
)
}
func TestThatStringContainsHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").Contains("art")
mockT.HasNoErrors()
}
func TestThatStringContainsHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").Contains("Michal")
mockT.HasErrorMessages(
"Expected string <Marta> to contain <Michal>, but didn't.",
)
}
func TestThatStringDoesNotContainHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").DoesNotContain("Michal")
mockT.HasNoErrors()
}
func TestThatStringDoesNotContainHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").DoesNotContain("art")
mockT.HasErrorMessages(
"Expected string <Marta> to not contain <art>, but it did.",
)
}
func TestThatStringIsLowerCaseHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("marta").IsLowerCase()
mockT.HasNoErrors()
}
func TestThatStringIsLowerCaseHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Marta").IsLowerCase()
mockT.HasErrorMessages(
"Expected string <Marta> to be lower case, but wasn't.",
)
}
func TestThatStringIsUpperCaseHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("MARTA").IsUpperCase()
mockT.HasNoErrors()
}
func TestThatStringIsUpperCaseHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("MArTa").IsUpperCase()
mockT.HasErrorMessages(
"Expected string <MArTa> to be upper case, but wasn't.",
)
}
func TestThatStringIsNotLowerCaseHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("MArta").IsNotLowerCase()
mockT.HasNoErrors()
}
func TestThatStringIsNotLowerCaseHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("marta").IsNotLowerCase()
mockT.HasErrorMessages(
"Expected string <marta> to not be lower case, but was.",
)
}
func TestThatStringIsNotUpperCaseHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("MArta").IsNotUpperCase()
mockT.HasNoErrors()
}
func TestThatStringIsNotUpperCaseHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("MARTA").IsNotUpperCase()
mockT.HasErrorMessages(
"Expected string <MARTA> to not be upper case, but was.",
)
}
func TestThatStringMatchesHasNoErrors(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Ewelina").Matches("^Ewe(\\w+)")
mockT.HasNoErrors()
}
func TestThatStringMatchesHasErrorMessages(t *testing.T) {
assert, mockT := setupWithMockT(t)
assert.ThatString("Ewelina").Matches("ewelin?")
mockT.HasErrorMessages(
"Expected string <Ewelina> to match <ewelin?>, but didn't.",
)
}