package utl import ( "testing" ) func TestIsPhone(t *testing.T) { phones := []string{ "137234510452", "12398765434", "13604550543", "13456786543", "16703440355", "19100001111", "19200001111", } var b, bs bool var phone string phone = phones[0] bs, b = IsPhoneSimple(phone), IsPhone(phone) AssertFalse(bs, phone+" should not be phone", t) AssertFalse(b, phone+" should not be phone", t) phone = phones[1] bs, b = IsPhoneSimple(phone), IsPhone(phone) AssertTrue(bs, phone+" should be phone", t) AssertFalse(b, phone+" should not be phone", t) } func TestIsEmail(t *testing.T) { yes := IsEmail("y282@163.com") if !yes { t.Fatal("?") } yes = IsEmail("t23.yjd@gmail.com") if !yes { t.Fatal("??") } yes = IsEmail("2343@163.com") if !yes { t.Fatal("???") } } func TestIsAlpha(t *testing.T) { yes := IsAlpha("y282@163.com") if yes { t.Fatal("?") } yes = IsAlpha("t45") if !yes { t.Fatal("??") } yes = IsAlpha("234") if yes { t.Fatal("???") } } func TestIsSafePasswd(t *testing.T) { l, n, u, o := CheckPasswd("Ty234#") if !(l && n && u && o) { t.Fatal("what") } }