-
Notifications
You must be signed in to change notification settings - Fork 2
/
string_test.go
63 lines (53 loc) · 1.05 KB
/
string_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package goist_test
import (
"fmt"
"github.com/lleiiell/goist"
"testing"
)
func TestUuidSimple(t *testing.T) {
uid := goist.UuidSimple()
if len(uid) < 22 {
t.Error(len(uid), uid)
return
}
fmt.Println(uid)
}
func TestRandomStr(t *testing.T) {
str := goist.RandStr(5)
if len(str) != 5 {
t.Error(str)
return
}
str1 := goist.RandStr(5)
if len(str1) != 5 {
t.Error(str1)
return
}
fmt.Println(str)
fmt.Println(str1)
}
func ExampleStrIsEmpty() {
s1 := ""
s2 := "a bc"
s3 := " "
s4 := "\n \t"
fmt.Println(goist.IsStrEmpty(s1), goist.IsStrEmpty(s2), goist.IsStrEmpty(s3), goist.IsStrEmpty(s4))
// Output: true false true true
}
func ExampleMD5() {
fmt.Println(goist.MD5("hello"))
// Output: 5d41402abc4b2a76b9719d911017c592
}
func TestToken(t *testing.T) {
fmt.Println(goist.Token())
fmt.Println(goist.Token())
fmt.Println(goist.Token())
fmt.Println(goist.Token())
fmt.Println(goist.Token())
}
func TestIsAscii(t *testing.T) {
fmt.Println(goist.IsAscii("你好"))
fmt.Println(goist.IsAscii("hello"))
// Output: true
// false
}