@@ -38,6 +38,12 @@ func Test_any_to_int64(t *testing.T) {
3838 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
3939 should .Equal (int64 (10 ), val )
4040
41+ // bool part
42+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
43+ should .Equal (int64 (0 ), val )
44+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
45+ should .Equal (int64 (1 ), val )
46+
4147 should .Nil (jsoniter .UnmarshalFromString (`-10` , & val ))
4248 should .Equal (int64 (- 10 ), val )
4349 should .NotNil (jsoniter .UnmarshalFromString ("{}" , & val ))
@@ -57,6 +63,13 @@ func Test_any_to_int(t *testing.T) {
5763 should .Equal (10 , val )
5864 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
5965 should .Equal (10 , val )
66+
67+ // bool part
68+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
69+ should .Equal (0 , val )
70+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
71+ should .Equal (1 , val )
72+
6073 should .NotNil (jsoniter .UnmarshalFromString ("{}" , & val ))
6174 should .NotNil (jsoniter .UnmarshalFromString ("[]" , & val ))
6275 // large float to int
@@ -74,6 +87,13 @@ func Test_any_to_int16(t *testing.T) {
7487 should .Equal (int16 (10 ), val )
7588 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
7689 should .Equal (int16 (10 ), val )
90+
91+ // bool part
92+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
93+ should .Equal (int16 (0 ), val )
94+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
95+ should .Equal (int16 (1 ), val )
96+
7797 should .NotNil (jsoniter .UnmarshalFromString ("{}" , & val ))
7898 should .NotNil (jsoniter .UnmarshalFromString ("[]" , & val ))
7999 // large float to int
@@ -91,6 +111,13 @@ func Test_any_to_int32(t *testing.T) {
91111 should .Equal (int32 (10 ), val )
92112 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
93113 should .Equal (int32 (10 ), val )
114+
115+ // bool part
116+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
117+ should .Equal (int32 (0 ), val )
118+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
119+ should .Equal (int32 (1 ), val )
120+
94121 should .NotNil (jsoniter .UnmarshalFromString ("{}" , & val ))
95122 should .NotNil (jsoniter .UnmarshalFromString ("[]" , & val ))
96123 // large float to int
@@ -108,6 +135,13 @@ func Test_any_to_int8(t *testing.T) {
108135 should .Equal (int8 (10 ), val )
109136 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
110137 should .Equal (int8 (10 ), val )
138+
139+ // bool part
140+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
141+ should .Equal (int8 (0 ), val )
142+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
143+ should .Equal (int8 (1 ), val )
144+
111145 should .NotNil (jsoniter .UnmarshalFromString ("{}" , & val ))
112146 should .NotNil (jsoniter .UnmarshalFromString ("[]" , & val ))
113147 // large float to int
@@ -125,6 +159,13 @@ func Test_any_to_uint8(t *testing.T) {
125159 should .Equal (uint8 (10 ), val )
126160 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
127161 should .Equal (uint8 (10 ), val )
162+
163+ // bool part
164+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
165+ should .Equal (uint8 (0 ), val )
166+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
167+ should .Equal (uint8 (1 ), val )
168+
128169 should .NotNil (jsoniter .UnmarshalFromString ("{}" , & val ))
129170 should .NotNil (jsoniter .UnmarshalFromString ("[]" , & val ))
130171 // large float to int
@@ -144,6 +185,12 @@ func Test_any_to_uint64(t *testing.T) {
144185 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
145186 should .Equal (uint64 (10 ), val )
146187
188+ // bool part
189+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
190+ should .Equal (uint64 (0 ), val )
191+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
192+ should .Equal (uint64 (1 ), val )
193+
147194 // TODO fix?
148195 should .NotNil (jsoniter .UnmarshalFromString (`-10` , & val ))
149196 should .Equal (uint64 (0 ), val )
@@ -165,6 +212,12 @@ func Test_any_to_uint32(t *testing.T) {
165212 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
166213 should .Equal (uint32 (10 ), val )
167214
215+ // bool part
216+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
217+ should .Equal (uint32 (0 ), val )
218+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
219+ should .Equal (uint32 (1 ), val )
220+
168221 // TODO fix?
169222 should .NotNil (jsoniter .UnmarshalFromString (`-10` , & val ))
170223 should .Equal (uint32 (0 ), val )
@@ -186,6 +239,12 @@ func Test_any_to_uint16(t *testing.T) {
186239 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
187240 should .Equal (uint16 (10 ), val )
188241
242+ // bool part
243+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
244+ should .Equal (uint16 (0 ), val )
245+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
246+ should .Equal (uint16 (1 ), val )
247+
189248 // TODO fix?
190249 should .NotNil (jsoniter .UnmarshalFromString (`-10` , & val ))
191250 should .Equal (uint16 (0 ), val )
@@ -205,6 +264,12 @@ func Test_any_to_uint(t *testing.T) {
205264 should .Equal (uint (10 ), val )
206265 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
207266 should .Equal (uint (10 ), val )
267+
268+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
269+ should .Equal (uint (0 ), val )
270+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
271+ should .Equal (uint (1 ), val )
272+
208273 should .NotNil (jsoniter .UnmarshalFromString ("{}" , & val ))
209274 should .NotNil (jsoniter .UnmarshalFromString ("[]" , & val ))
210275 // large float to int
@@ -223,6 +288,13 @@ func Test_any_to_float32(t *testing.T) {
223288 should .Equal (float32 (10.1 ), val )
224289 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
225290 should .Equal (float32 (10 ), val )
291+
292+ // bool part
293+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
294+ should .Equal (float32 (0 ), val )
295+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
296+ should .Equal (float32 (1 ), val )
297+
226298 should .NotNil (jsoniter .UnmarshalFromString ("{}" , & val ))
227299 should .NotNil (jsoniter .UnmarshalFromString ("[]" , & val ))
228300}
@@ -240,6 +312,13 @@ func Test_any_to_float64(t *testing.T) {
240312 should .Equal (float64 (10.1 ), val )
241313 should .Nil (jsoniter .UnmarshalFromString (`10` , & val ))
242314 should .Equal (float64 (10 ), val )
315+
316+ // bool part
317+ should .Nil (jsoniter .UnmarshalFromString (`false` , & val ))
318+ should .Equal (float64 (0 ), val )
319+ should .Nil (jsoniter .UnmarshalFromString (`true` , & val ))
320+ should .Equal (float64 (1 ), val )
321+
243322 should .NotNil (jsoniter .UnmarshalFromString ("{}" , & val ))
244323 should .NotNil (jsoniter .UnmarshalFromString ("[]" , & val ))
245324}
0 commit comments