...
1
2
17
18 package issue_test
19
20 import (
21 `testing`
22
23 `encoding/json`
24 . `github.com/bytedance/sonic`
25 `github.com/stretchr/testify/require`
26 )
27
28 func TestIssue_UnmarshalBase64(t *testing.T) {
29 var obj, stdobj []byte
30 tests := []string {
31 `"xy\r\nzu"`,
32 `"xy\/\/"`,
33 `"\/\/=="`,
34 `"\/\/\u003d\u003d"`,
35 `"\u0030\u0030\u0030\u003d"`,
36 }
37 for _, data := range(tests) {
38 stderr := json.Unmarshal([]byte(data), &stdobj)
39 err := Unmarshal([]byte(data), &obj)
40 require.NoError(t, stderr, data)
41 require.NoError(t, err, data)
42 require.Equal(t, stdobj, obj, data)
43 }
44 }
45
46 func TestIssue_UnmarshalBase64Error(t *testing.T) {
47 var obj, stdobj []byte
48 tests := []string {
49 `"xy\r\nzu0==="`,
50 `"xy\/\/`,
51 `"\/\/==`,
52 `"\/\/\u003d0\u003d"`,
53 `"\u0030\u0030\u0030\u003d`,
54 }
55 for _, data := range(tests) {
56 stderr := json.Unmarshal([]byte(data), &stdobj)
57 err := Unmarshal([]byte(data), &obj)
58 require.Equal(t, stderr != nil, err != nil)
59 }
60 var _, _ = obj, stdobj
61 }
View as plain text