-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse_test.go
131 lines (108 loc) · 2.11 KB
/
parse_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package quirk
import (
"testing"
. "github.com/franela/goblin"
)
func BenchmarkReflectMaps(b *testing.B) {
c := NewClient()
data := testPersonCorrect // from testing.go
for i := 0; i < b.N; i++ {
_ = c.reflectMaps(&data)
}
}
func BenchmarkParseTag(b *testing.B) {
data := "1,2"
for i := 0; i < b.N; i++ {
_, _ = parseTag(data)
}
}
func TestParseTag(t *testing.T) {
g := Goblin(t)
g.Describe("Parsed Tags", func() {
g.It("Should equal \"1\", \"2\"", func(done Done) {
go func() {
a, b := parseTag("1,2")
g.Assert(a).
Equal("1")
g.Assert(b).
Equal(tagOptions("2"))
done()
}()
})
g.It("Should equal \"1\", \"\"", func(done Done) {
go func() {
a, b := parseTag("1,")
g.Assert(a).
Equal("1")
g.Assert(b).
Equal(tagOptions(""))
done()
}()
})
})
}
func TestCheckType(t *testing.T) {
g := Goblin(t)
g.Describe("XML Datatype", func() {
g.It("Should be an int with int", func() {
var a int
b := checkType(a)
g.Assert(b).
Equal(xsInt)
})
g.It("Should be an int with int64", func() {
var a int64
b := checkType(a)
g.Assert(b).
Equal(xsInt)
})
g.It("Should be an int with int32", func() {
var a int32
b := checkType(a)
g.Assert(b).
Equal(xsInt)
})
g.It("Should be an int with int16", func() {
var a int16
b := checkType(a)
g.Assert(b).
Equal(xsInt)
})
g.It("Should be an int with int8", func() {
var a int8
b := checkType(a)
g.Assert(b).
Equal(xsInt)
})
g.It("Should be bool with bool", func() {
var a bool
b := checkType(a)
g.Assert(b).
Equal(xsBool)
})
g.It("Should be float with float32", func() {
var a float32
b := checkType(a)
g.Assert(b).
Equal(xsFloat)
})
g.It("Should be float with float64", func() {
var a float64
b := checkType(a)
g.Assert(b).
Equal(xsFloat)
})
g.It("Should be empty with string", func() {
var a string
b := checkType(a)
g.Assert(b).
Equal("")
})
g.It("Should be byte with byte slice", func() {
var a []byte
b := checkType(a)
g.Assert(b).
Equal(xsString)
})
})
}