Skip to content

Commit 477be43

Browse files
committed
consolidate more tests
1 parent a8708bc commit 477be43

15 files changed

+329
-913
lines changed

jsoniter_wrap_test.go renamed to any_tests/jsoniter_wrap_test.go

+37-36
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,117 @@
1-
package jsoniter
1+
package any_tests
22

33
import (
44
"testing"
55

66
"github.com/stretchr/testify/require"
7+
"github.com/json-iterator/go"
78
)
89

910
func Test_wrap_and_valuetype_everything(t *testing.T) {
1011
should := require.New(t)
1112
var i interface{}
12-
any := Get([]byte("123"))
13+
any := jsoniter.Get([]byte("123"))
1314
// default of number type is float64
1415
i = float64(123)
1516
should.Equal(i, any.GetInterface())
1617

17-
any = Wrap(int8(10))
18-
should.Equal(any.ValueType(), NumberValue)
18+
any = jsoniter.Wrap(int8(10))
19+
should.Equal(any.ValueType(), jsoniter.NumberValue)
1920
should.Equal(any.LastError(), nil)
2021
// get interface is not int8 interface
2122
// i = int8(10)
2223
// should.Equal(i, any.GetInterface())
2324

24-
any = Wrap(int16(10))
25-
should.Equal(any.ValueType(), NumberValue)
25+
any = jsoniter.Wrap(int16(10))
26+
should.Equal(any.ValueType(), jsoniter.NumberValue)
2627
should.Equal(any.LastError(), nil)
2728
//i = int16(10)
2829
//should.Equal(i, any.GetInterface())
2930

30-
any = Wrap(int32(10))
31-
should.Equal(any.ValueType(), NumberValue)
31+
any = jsoniter.Wrap(int32(10))
32+
should.Equal(any.ValueType(), jsoniter.NumberValue)
3233
should.Equal(any.LastError(), nil)
3334
i = int32(10)
3435
should.Equal(i, any.GetInterface())
35-
any = Wrap(int64(10))
36-
should.Equal(any.ValueType(), NumberValue)
36+
any = jsoniter.Wrap(int64(10))
37+
should.Equal(any.ValueType(), jsoniter.NumberValue)
3738
should.Equal(any.LastError(), nil)
3839
i = int64(10)
3940
should.Equal(i, any.GetInterface())
4041

41-
any = Wrap(uint(10))
42-
should.Equal(any.ValueType(), NumberValue)
42+
any = jsoniter.Wrap(uint(10))
43+
should.Equal(any.ValueType(), jsoniter.NumberValue)
4344
should.Equal(any.LastError(), nil)
4445
// not equal
4546
//i = uint(10)
4647
//should.Equal(i, any.GetInterface())
47-
any = Wrap(uint8(10))
48-
should.Equal(any.ValueType(), NumberValue)
48+
any = jsoniter.Wrap(uint8(10))
49+
should.Equal(any.ValueType(), jsoniter.NumberValue)
4950
should.Equal(any.LastError(), nil)
5051
// not equal
5152
// i = uint8(10)
5253
// should.Equal(i, any.GetInterface())
53-
any = Wrap(uint16(10))
54-
should.Equal(any.ValueType(), NumberValue)
54+
any = jsoniter.Wrap(uint16(10))
55+
should.Equal(any.ValueType(), jsoniter.NumberValue)
5556
should.Equal(any.LastError(), nil)
56-
any = Wrap(uint32(10))
57-
should.Equal(any.ValueType(), NumberValue)
57+
any = jsoniter.Wrap(uint32(10))
58+
should.Equal(any.ValueType(), jsoniter.NumberValue)
5859
should.Equal(any.LastError(), nil)
5960
i = uint32(10)
6061
should.Equal(i, any.GetInterface())
61-
any = Wrap(uint64(10))
62-
should.Equal(any.ValueType(), NumberValue)
62+
any = jsoniter.Wrap(uint64(10))
63+
should.Equal(any.ValueType(), jsoniter.NumberValue)
6364
should.Equal(any.LastError(), nil)
6465
i = uint64(10)
6566
should.Equal(i, any.GetInterface())
6667

67-
any = Wrap(float32(10))
68-
should.Equal(any.ValueType(), NumberValue)
68+
any = jsoniter.Wrap(float32(10))
69+
should.Equal(any.ValueType(), jsoniter.NumberValue)
6970
should.Equal(any.LastError(), nil)
7071
// not equal
7172
//i = float32(10)
7273
//should.Equal(i, any.GetInterface())
73-
any = Wrap(float64(10))
74-
should.Equal(any.ValueType(), NumberValue)
74+
any = jsoniter.Wrap(float64(10))
75+
should.Equal(any.ValueType(), jsoniter.NumberValue)
7576
should.Equal(any.LastError(), nil)
7677
i = float64(10)
7778
should.Equal(i, any.GetInterface())
7879

79-
any = Wrap(true)
80-
should.Equal(any.ValueType(), BoolValue)
80+
any = jsoniter.Wrap(true)
81+
should.Equal(any.ValueType(), jsoniter.BoolValue)
8182
should.Equal(any.LastError(), nil)
8283
i = true
8384
should.Equal(i, any.GetInterface())
84-
any = Wrap(false)
85-
should.Equal(any.ValueType(), BoolValue)
85+
any = jsoniter.Wrap(false)
86+
should.Equal(any.ValueType(), jsoniter.BoolValue)
8687
should.Equal(any.LastError(), nil)
8788
i = false
8889
should.Equal(i, any.GetInterface())
8990

90-
any = Wrap(nil)
91-
should.Equal(any.ValueType(), NilValue)
91+
any = jsoniter.Wrap(nil)
92+
should.Equal(any.ValueType(), jsoniter.NilValue)
9293
should.Equal(any.LastError(), nil)
9394
i = nil
9495
should.Equal(i, any.GetInterface())
9596

96-
stream := NewStream(ConfigDefault, nil, 32)
97+
stream := jsoniter.NewStream(jsoniter.ConfigDefault, nil, 32)
9798
any.WriteTo(stream)
9899
should.Equal("null", string(stream.Buffer()))
99100
should.Equal(any.LastError(), nil)
100101

101-
any = Wrap(struct{ age int }{age: 1})
102-
should.Equal(any.ValueType(), ObjectValue)
102+
any = jsoniter.Wrap(struct{ age int }{age: 1})
103+
should.Equal(any.ValueType(), jsoniter.ObjectValue)
103104
should.Equal(any.LastError(), nil)
104105
i = struct{ age int }{age: 1}
105106
should.Equal(i, any.GetInterface())
106107

107-
any = Wrap(map[string]interface{}{"abc": 1})
108-
should.Equal(any.ValueType(), ObjectValue)
108+
any = jsoniter.Wrap(map[string]interface{}{"abc": 1})
109+
should.Equal(any.ValueType(), jsoniter.ObjectValue)
109110
should.Equal(any.LastError(), nil)
110111
i = map[string]interface{}{"abc": 1}
111112
should.Equal(i, any.GetInterface())
112113

113-
any = Wrap("abc")
114+
any = jsoniter.Wrap("abc")
114115
i = "abc"
115116
should.Equal(i, any.GetInterface())
116117
should.Equal(nil, any.LastError())

jsoniter_sloppy_test.go renamed to feature_iter_skip_sloppy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//+build jsoniter-sloppy
1+
//+build jsoniter_sloppy
22

33
package jsoniter
44

File renamed without changes.

jsoniter_reader_test.go

-57
This file was deleted.

jsoniter_reflect_native_test.go

-154
This file was deleted.

0 commit comments

Comments
 (0)