package userValidator
import (
"testing"
)
func TestValideUsername(t *testing.T) {
tests := []struct {
Username string
Expected bool
}{
{
"lol",
true,
},
"àçésdsd",
"[}\\_",
false,
"^!",
"test ",
"test done",
"れんちょん",
"",
}
for _, val := range tests {
testVal := ValidateUsername(val.Username)
if testVal != val.Expected {
t.Errorf("The test returned a result %t instead of %t for '%s'", testVal, val.Expected, val.Username)
func TestEmailValidation(t *testing.T) {
tests := [][]interface{}{
"lol@xd.uu",
"someone.might.wann@this.mail",
"disposable.style.email.with+symbol@example.com",
"other.email-with-dash@example.com",
"x@example.com",
`"very.unusual.@.unusual.com"@example.com`,
`very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"@strange.example.com`,
"example-indeed@strange-example.com",
"admin@mailserver1",
"#!$%&'*+-/=?^_`{}|~@example.org",
`"()<>[]:,;@\\\"!#$%&'-/=?^_` + "`" + `{}| ~.a"@example.org`,
`" "@example.org`,
`example@s.solutions`,
`Abc.example.com`,
`A@b@c@example.com`,
`a"b(c)d,e:f;g<h>i[j\k]l@example.com`,
`just"not"right@example.com`,
`this is"not\allowed@example.com`,
`to\ to@xn-fsqu00a.xn-0zwm56d`,
`1234567890123456789012345678901234567890123456789012345678901234+2323232@example.com`,
`john..doe@example.com`,
`john.doe@example..com`,
`toto@[192.168.1.1]`,
testVal := EmailValidation(val[0].(string))
if testVal != val[1] {
t.Errorf("The test returned a result %t instead of %t for %s", testVal, val[1].(bool), val[0].(string))