package userValidator
import (
"testing"
"github.com/NyaaPantsu/nyaa/utils/validator"
)
func TestValideUsername(t *testing.T) {
tests := [][]interface{}{
{
"lol",
true,
},
"àçésdsd",
"[}\\_",
false,
"^!",
"test ",
"test done",
"れんちょん",
}
for _, val := range tests {
testVal := validator.IsUTFLetterNumeric(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))
func TestEmailValidation(t *testing.T) {
"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))