@@ -28,6 +28,8 @@ type Basic struct {
28
28
VjsonUint64 uint64
29
29
VjsonFloat float64
30
30
VjsonNumber json.Number
31
+ Vcomplex64 complex64
32
+ Vcomplex128 complex128
31
33
}
32
34
33
35
type BasicPointer struct {
@@ -248,6 +250,8 @@ func TestBasicTypes(t *testing.T) {
248
250
"vjsonUint64" : json .Number ("9223372036854775809" ), // 2^63 + 1
249
251
"vjsonFloat" : json .Number ("1234.5" ),
250
252
"vjsonNumber" : json .Number ("1234.5" ),
253
+ "vcomplex64" : complex (float32 (42 ), float32 (42 )),
254
+ "vcomplex128" : complex (42 , 42 ),
251
255
}
252
256
253
257
var result Basic
@@ -320,6 +324,14 @@ func TestBasicTypes(t *testing.T) {
320
324
if ! reflect .DeepEqual (result .VjsonNumber , json .Number ("1234.5" )) {
321
325
t .Errorf ("vjsonnumber value should be '1234.5': %T, %#v" , result .VjsonNumber , result .VjsonNumber )
322
326
}
327
+
328
+ if real (result .Vcomplex64 ) != 42 || imag (result .Vcomplex64 ) != 42 {
329
+ t .Errorf ("vcomplex64 value shou be 42+42i: %#v" , result .Vcomplex64 )
330
+ }
331
+
332
+ if real (result .Vcomplex128 ) != 42 || imag (result .Vcomplex128 ) != 42 {
333
+ t .Errorf ("vcomplex64 value shou be 42+42i: %#v" , result .Vcomplex128 )
334
+ }
323
335
}
324
336
325
337
func TestBasic_IntWithFloat (t * testing.T ) {
@@ -1933,6 +1945,8 @@ func TestDecodeTable(t *testing.T) {
1933
1945
"VjsonUint64" : uint64 (0 ),
1934
1946
"VjsonFloat" : 0.0 ,
1935
1947
"VjsonNumber" : json .Number ("" ),
1948
+ "Vcomplex64" : complex64 (0 ),
1949
+ "Vcomplex128" : complex128 (0 ),
1936
1950
},
1937
1951
false ,
1938
1952
},
@@ -1975,6 +1989,8 @@ func TestDecodeTable(t *testing.T) {
1975
1989
"VjsonUint64" : uint64 (0 ),
1976
1990
"VjsonFloat" : 0.0 ,
1977
1991
"VjsonNumber" : json .Number ("" ),
1992
+ "Vcomplex64" : complex64 (0 ),
1993
+ "Vcomplex128" : complex128 (0 ),
1978
1994
},
1979
1995
},
1980
1996
false ,
0 commit comments