@@ -193,6 +193,7 @@ func TestEmail(t *testing.T) {
193
193
// unicode char included
194
194
validStartingCharacters := strings .Split ("!#$%^&*_+1234567890abcdefghijklmnopqrstuvwxyzñ" , "" )
195
195
invalidCharacters := strings .Split (" ()" , "" )
196
+
196
197
definiteInvalidDomains := []string {
197
198
"" , // any empty string (x@)
198
199
".com" , // only the TLD (x@.com)
@@ -212,20 +213,20 @@ func TestEmail(t *testing.T) {
212
213
for _ , startingChar := range validStartingCharacters {
213
214
currentEmail = fmt .Sprintf ("%sñbc+123@do-main.com" , startingChar )
214
215
if email .IsSatisfied (currentEmail ) {
215
- t .Errorf (noErrorsMessage , fmt .Sprintf ("email = %s" , currentEmail ))
216
+ t .Errorf (noErrorsMessage , "starting characters" , fmt .Sprintf ("email = %s" , currentEmail ))
216
217
}
217
218
218
219
// validation should fail because of multiple @ symbols
219
220
currentEmail = fmt .Sprintf ("%s@ñbc+123@do-main.com" , startingChar )
220
221
if email .IsSatisfied (currentEmail ) {
221
- t .Errorf (errorsMessage , fmt .Sprintf ("email = %s" , currentEmail ))
222
+ t .Errorf (errorsMessage , "starting characters with multiple @ symbols" , fmt .Sprintf ("email = %s" , currentEmail ))
222
223
}
223
224
224
225
// should fail simply because of the invalid char
225
226
for _ , invalidChar := range invalidCharacters {
226
227
currentEmail = fmt .Sprintf ("%sñbc%s+123@do-main.com" , startingChar , invalidChar )
227
228
if email .IsSatisfied (currentEmail ) {
228
- t .Errorf (errorsMessage , fmt .Sprintf ("email = %s" , currentEmail ))
229
+ t .Errorf (errorsMessage , "invalid starting characters" , fmt .Sprintf ("email = %s" , currentEmail ))
229
230
}
230
231
}
231
232
}
@@ -234,21 +235,21 @@ func TestEmail(t *testing.T) {
234
235
for _ , invalidDomain := range definiteInvalidDomains {
235
236
currentEmail = fmt .Sprintf ("a@%s" , invalidDomain )
236
237
if email .IsSatisfied (currentEmail ) {
237
- t .Errorf (errorsMessage , fmt .Sprintf ("email = %s" , currentEmail ))
238
+ t .Errorf (errorsMessage , "invalid domain" , fmt .Sprintf ("email = %s" , currentEmail ))
238
239
}
239
240
}
240
241
241
242
// should always be satisfied
242
243
if ! email .IsSatisfied ("t0.est+email123@1abc0-def.com" ) {
243
- t .Errorf (noErrorsMessage , fmt .Sprintf ("email = %s" , "t0.est+email123@1abc0-def.com" ))
244
+ t .Errorf (noErrorsMessage , "guarunteed valid email" , fmt .Sprintf ("email = %s" , "t0.est+email123@1abc0-def.com" ))
244
245
}
245
246
246
247
// should never be satisfied (this is redundant given the loops above)
247
248
if email .IsSatisfied ("a@xcom" ) {
248
- t .Errorf (noErrorsMessage , fmt .Sprintf ("email = %s" , "a@xcom" ))
249
+ t .Errorf (noErrorsMessage , "guaranteed invalid email" , fmt .Sprintf ("email = %s" , "a@xcom" ))
249
250
}
250
251
if email .IsSatisfied ("a@@x.com" ) {
251
- t .Errorf (noErrorsMessage , fmt .Sprintf ("email = %s" , "a@@x.com" ))
252
+ t .Errorf (noErrorsMessage , "guaranteed invaild email" , fmt .Sprintf ("email = %s" , "a@@x.com" ))
252
253
}
253
254
}
254
255
}
0 commit comments