MCPcopy
hub / github.com/purpleidea/mgmt / TestValueOfJSON1

Function TestValueOfJSON1

lang/types/json/json_test.go:56–276  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func TestValueOfJSON1(t *testing.T) {
57 testCases := []struct {
58 str string
59 typ *types.Type
60 val types.Value
61 }{
62 {
63 str: "false",
64 typ: types.NewType("bool"), // we can infer these!
65 val: &types.BoolValue{V: false},
66 },
67 {
68 str: "true",
69 val: &types.BoolValue{V: true},
70 },
71 {
72 str: `""`, // not empty string, but two quotes!
73 val: &types.StrValue{V: ""},
74 },
75 {
76 str: `"hello"`,
77 val: &types.StrValue{V: "hello"},
78 },
79 {
80 str: `"hello\tworld"`,
81 val: &types.StrValue{V: "hello\tworld"},
82 },
83 {
84 str: `"hello\nworld"`,
85 val: &types.StrValue{V: "hello\nworld"},
86 },
87 {
88 str: `"hello\\world"`,
89 val: &types.StrValue{V: "hello\\world"},
90 },
91 {
92 str: `"hello\t\nworld"`,
93 val: &types.StrValue{V: "hello\t\nworld"},
94 },
95 {
96 str: `"\\"`,
97 val: &types.StrValue{V: "\\"},
98 },
99 {
100 str: "0",
101 val: &types.IntValue{V: 0},
102 },
103 {
104 str: "0",
105 val: &types.IntValue{V: -0},
106 },
107 {
108 str: "42",
109 val: &types.IntValue{V: 42},
110 },
111 {
112 str: "-13",
113 val: &types.IntValue{V: -13},

Callers

nothing calls this directly

Calls 10

NewTypeFunction · 0.92
NewMapFunction · 0.92
NewStructFunction · 0.92
ValueOfJSONFunction · 0.85
LogfMethod · 0.80
SetMethod · 0.65
TypeMethod · 0.65
CmpMethod · 0.65
testStruct · 0.50
RunMethod · 0.45

Tested by

no test coverage detected