MCPcopy Create free account
hub / github.com/francoispqt/gojay / TestDecodeInterfaceBasic

Function TestDecodeInterfaceBasic

decode_interface_test.go:11–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestDecodeInterfaceBasic(t *testing.T) {
12 testCases := []struct {
13 name string
14 json string
15 expectedResult interface{}
16 err bool
17 errType interface{}
18 skipCheckResult bool
19 }{
20 {
21 name: "array",
22 json: `[1,2,3]`,
23 expectedResult: []interface{}([]interface{}{float64(1), float64(2), float64(3)}),
24 err: false,
25 },
26 {
27 name: "object",
28 json: `{"testStr": "hello world!"}`,
29 expectedResult: map[string]interface{}(map[string]interface{}{"testStr": "hello world!"}),
30 err: false,
31 },
32 {
33 name: "string",
34 json: `"hola amigos!"`,
35 expectedResult: interface{}("hola amigos!"),
36 err: false,
37 },
38 {
39 name: "bool-true",
40 json: `true`,
41 expectedResult: interface{}(true),
42 err: false,
43 },
44 {
45 name: "bool-false",
46 json: `false`,
47 expectedResult: interface{}(false),
48 err: false,
49 },
50 {
51 name: "null",
52 json: `null`,
53 expectedResult: interface{}(nil),
54 err: false,
55 },
56 {
57 name: "number",
58 json: `1234`,
59 expectedResult: interface{}(float64(1234)),
60 err: false,
61 },
62 {
63 name: "array-error",
64 json: `["h""o","l","a"]`,
65 err: true,
66 errType: &json.SyntaxError{},
67 skipCheckResult: true,
68 },

Callers

nothing calls this directly

Calls 5

InvalidJSONErrorTypeAlias · 0.85
BorrowDecoderFunction · 0.85
DecodeInterfaceMethod · 0.80
DecodeMethod · 0.80
ReleaseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…