| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 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")
- }
- }
|