-
Notifications
You must be signed in to change notification settings - Fork 0
/
string_test.go
59 lines (49 loc) · 1.16 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
package buzz
import (
"testing"
)
func Test_StringEmailSuccess(t *testing.T) {
if err := String().Email().Validate("[email protected]"); err != nil {
t.FailNow()
}
}
func Test_StringEmailFail(t *testing.T) {
if err := String().Email().Validate("ahmetmail.com"); err == nil {
t.FailNow()
}
}
func Test_StringMinSuccess(t *testing.T) {
if err := String().Min(2).Validate("ahmet"); err != nil {
t.FailNow()
}
}
func Test_StringMinFail(t *testing.T) {
if err := String().Min(2).Validate("a"); err == nil {
t.FailNow()
}
}
func Test_StringMaxSuccess(t *testing.T) {
if err := String().Max(10).Validate("ahmet"); err != nil {
t.FailNow()
}
}
func Test_StringMaxFail(t *testing.T) {
if err := String().Max(10).Validate("ahmetyazici"); err == nil {
t.FailNow()
}
}
func Test_StringLenSuccess(t *testing.T) {
if err := String().Len(5).Validate("ahmet"); err != nil {
t.FailNow()
}
}
func Test_StringLenFail(t *testing.T) {
if err := String().Len(5).Validate("ahmetyazici"); err == nil {
t.FailNow()
}
}
func Test_StringUUIDSuccess(t *testing.T) {
if err := String().UUID().Validate("096653e9-32e1-4325-86ff-b316596b5a9a"); err != nil {
t.FailNow()
}
}