-
Notifications
You must be signed in to change notification settings - Fork 2
/
streamer_int_test.go
204 lines (192 loc) · 3.94 KB
/
streamer_int_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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package jzon
import (
"math"
"testing"
)
func TestStreamer_Int_ChainError(t *testing.T) {
t.Run("int8", func(t *testing.T) {
testStreamerChainError(t, func(s *Streamer) {
s.Int8(1)
})
})
t.Run("int16", func(t *testing.T) {
testStreamerChainError(t, func(s *Streamer) {
s.Int16(1)
})
})
t.Run("int32", func(t *testing.T) {
testStreamerChainError(t, func(s *Streamer) {
s.Int32(1)
})
})
t.Run("int64", func(t *testing.T) {
testStreamerChainError(t, func(s *Streamer) {
s.Int64(1)
})
})
t.Run("uint8", func(t *testing.T) {
testStreamerChainError(t, func(s *Streamer) {
s.Uint8(1)
})
})
t.Run("uint16", func(t *testing.T) {
testStreamerChainError(t, func(s *Streamer) {
s.Uint16(1)
})
})
t.Run("uint32", func(t *testing.T) {
testStreamerChainError(t, func(s *Streamer) {
s.Uint32(1)
})
})
t.Run("uint64", func(t *testing.T) {
testStreamerChainError(t, func(s *Streamer) {
s.Uint64(1)
})
})
}
func TestStreamer_Int8(t *testing.T) {
f := func(t *testing.T, i int8) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Int8(i)
}, nil)
}
t.Run("max", func(t *testing.T) {
f(t, math.MaxInt8)
})
t.Run("min", func(t *testing.T) {
f(t, math.MinInt8)
})
}
func TestStreamer_Uint8(t *testing.T) {
f := func(t *testing.T, i uint8) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Uint8(i)
}, nil)
}
t.Run("max", func(t *testing.T) {
f(t, math.MaxUint8)
})
t.Run("min", func(t *testing.T) {
f(t, 0)
})
}
func TestStreamer_Int16(t *testing.T) {
f := func(t *testing.T, i int16) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Int16(i)
}, nil)
}
t.Run("max", func(t *testing.T) {
f(t, math.MaxInt16)
})
t.Run("min", func(t *testing.T) {
f(t, math.MinInt16)
})
}
func TestStreamer_Uint16(t *testing.T) {
f := func(t *testing.T, i uint16) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Uint16(i)
}, nil)
}
t.Run("max", func(t *testing.T) {
f(t, math.MaxUint16)
})
t.Run("min", func(t *testing.T) {
f(t, 0)
})
}
func TestStreamer_Int32(t *testing.T) {
f := func(t *testing.T, i int32) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Int32(i)
}, nil)
}
t.Run("max", func(t *testing.T) {
f(t, math.MaxInt32)
})
t.Run("min", func(t *testing.T) {
f(t, math.MinInt32)
})
}
func TestStreamer_Uint32(t *testing.T) {
f := func(t *testing.T, i uint32) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Uint32(i)
}, nil)
}
t.Run("max", func(t *testing.T) {
f(t, math.MaxUint32)
})
t.Run("min", func(t *testing.T) {
f(t, 0)
})
t.Run("1023", func(t *testing.T) {
f(t, 1023)
})
t.Run("1023045", func(t *testing.T) {
f(t, 1023045)
})
}
func TestStreamer_Int64(t *testing.T) {
f := func(t *testing.T, i int64) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Int64(i)
}, nil)
}
t.Run("max", func(t *testing.T) {
f(t, math.MaxInt64)
})
t.Run("min", func(t *testing.T) {
f(t, math.MinInt64)
})
}
func TestStreamer_Uint64(t *testing.T) {
f := func(t *testing.T, i uint64) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Uint64(i)
}, nil)
}
t.Run("max", func(t *testing.T) {
f(t, math.MaxUint64)
})
t.Run("min", func(t *testing.T) {
f(t, 0)
})
t.Run("1023", func(t *testing.T) {
f(t, 1023)
})
t.Run("1023045", func(t *testing.T) {
f(t, 1023045)
})
t.Run("1023045067", func(t *testing.T) {
f(t, 1023045067)
})
t.Run("1023045067089", func(t *testing.T) {
f(t, 1023045067089)
})
t.Run("1023045067089000", func(t *testing.T) {
f(t, 1023045067089000)
})
}
func TestStreamer_Int(t *testing.T) {
f := func(t *testing.T, i int) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Int(i)
}, nil)
}
t.Run("test", func(t *testing.T) {
f(t, math.MaxInt32)
})
}
func TestStreamer_Uint(t *testing.T) {
f := func(t *testing.T, i uint) {
checkEncodeWithStandard(t, i, func(s *Streamer) {
s.Uint(i)
}, nil)
}
t.Run("test", func(t *testing.T) {
f(t, math.MaxUint32)
})
}