MCPcopy Index your code
hub / github.com/pquerna/ffjson / TestRefValMarshal

Function TestRefValMarshal

tests/encode_test.go:102–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestRefValMarshal(t *testing.T) {
103 var s = struct {
104 R0 Ref
105 R1 *Ref
106 R2 RefText
107 R3 *RefText
108 V0 Val
109 V1 *Val
110 V2 ValText
111 V3 *ValText
112 }{
113 R0: 12,
114 R1: new(Ref),
115 R2: 14,
116 R3: new(RefText),
117 V0: 13,
118 V1: new(Val),
119 V2: 15,
120 V3: new(ValText),
121 }
122 const want = `{"R0":"ref","R1":"ref","R2":"\"ref\"","R3":"\"ref\"","V0":"val","V1":"val","V2":"\"val\"","V3":"\"val\""}`
123 b, err := json.Marshal(&s)
124 if err != nil {
125 t.Fatalf("Marshal: %v", err)
126 }
127 if got := string(b); got != want {
128 t.Errorf("got %q, want %q", got, want)
129 }
130}
131
132func TestMarshalerEscaping(t *testing.T) {
133 var c C

Callers

nothing calls this directly

Calls 1

FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…