@@ -24,45 +24,47 @@ import (
24
24
`strings`
25
25
`testing`
26
26
27
+ `github.com/bytedance/sonic/option`
27
28
`github.com/stretchr/testify/assert`
28
29
`github.com/stretchr/testify/require`
29
30
)
30
31
31
32
var (
32
- _Single_JSON = `{"aaaaa":"` + strings .Repeat ("b" , int (defaultBufferSize )) + `"} { `
33
- _Double_JSON = `{"aaaaa":"` + strings .Repeat ("b" , int (defaultBufferSize )) + `"} {"11111":"` + strings .Repeat ("2" , int (defaultBufferSize )) + `"}`
34
- _Triple_JSON = `{"aaaaa":"` + strings .Repeat ("b" , int (defaultBufferSize )) + `"}{ } {"11111":"` +
35
- strings .Repeat ("2" , int (defaultBufferSize ))+ `"} b {}`
33
+ DefaultBufferSize = option .DefaultDecoderBufferSize
34
+ _Single_JSON = `{"aaaaa":"` + strings .Repeat ("b" , int (DefaultBufferSize )) + `"} { `
35
+ _Double_JSON = `{"aaaaa":"` + strings .Repeat ("b" , int (DefaultBufferSize )) + `"} {"11111":"` + strings .Repeat ("2" , int (DefaultBufferSize )) + `"}`
36
+ _Triple_JSON = `{"aaaaa":"` + strings .Repeat ("b" , int (DefaultBufferSize )) + `"}{ } {"11111":"` +
37
+ strings .Repeat ("2" , int (DefaultBufferSize ))+ `"} b {}`
36
38
)
37
39
38
40
func TestStreamError (t * testing.T ) {
39
41
var qs = []string {
40
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"` ,
41
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"}` ,
42
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `""}` ,
43
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":}` ,
44
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":]` ,
45
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":1x` ,
46
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":1x}` ,
47
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":1x]` ,
48
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":t` ,
49
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":t}` ,
50
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":true]` ,
51
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":f` ,
52
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":f}` ,
53
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":false]` ,
54
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":n` ,
55
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":n}` ,
56
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":null]` ,
57
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":"` ,
58
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":"a` ,
59
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":"a}` ,
60
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":"a"` ,
61
- `{` + strings .Repeat (" " , int (defaultBufferSize ))+ `"":"a"]` ,
42
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"` ,
43
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"}` ,
44
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `""}` ,
45
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":}` ,
46
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":]` ,
47
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":1x` ,
48
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":1x}` ,
49
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":1x]` ,
50
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":t` ,
51
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":t}` ,
52
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":true]` ,
53
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":f` ,
54
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":f}` ,
55
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":false]` ,
56
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":n` ,
57
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":n}` ,
58
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":null]` ,
59
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":"` ,
60
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":"a` ,
61
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":"a}` ,
62
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":"a"` ,
63
+ `{` + strings .Repeat (" " , int (DefaultBufferSize ))+ `"":"a"]` ,
62
64
}
63
65
64
66
for i , q := range qs {
65
- var qq = []byte (q [:int (defaultBufferSize )]+ strings .Repeat (" " , i * 100 )+ q [int (defaultBufferSize ):])
67
+ var qq = []byte (q [:int (DefaultBufferSize )]+ strings .Repeat (" " , i * 100 )+ q [int (DefaultBufferSize ):])
66
68
var obj interface {}
67
69
require .NotNil (t , NewStreamDecoder (bytes .NewReader (qq )).Decode (& obj ))
68
70
}
0 commit comments