MCPcopy Create free account
hub / github.com/pquerna/ffjson / TestEmbeddedBug

Function TestEmbeddedBug

tests/encode_test.go:169–196  ·  view source on GitHub ↗

Issue 5245.

(t *testing.T)

Source from the content-addressed store, hash-verified

167
168// Issue 5245.
169func TestEmbeddedBug(t *testing.T) {
170 v := BugB{
171 BugA{"A"},
172 "B",
173 }
174 b, err := json.Marshal(v)
175 if err != nil {
176 t.Fatal("Marshal:", err)
177 }
178 want := `{"S":"B"}`
179 got := string(b)
180 if got != want {
181 t.Fatalf("Marshal: got %s want %s", got, want)
182 }
183 // Now check that the duplicate field, S, does not appear.
184 x := BugX{
185 A: 23,
186 }
187 b, err = json.Marshal(x)
188 if err != nil {
189 t.Fatal("Marshal:", err)
190 }
191 want = `{"A":23}`
192 got = string(b)
193 if got != want {
194 t.Fatalf("Marshal: got %s want %s", got, want)
195 }
196}
197
198// Test that a field with a tag dominates untagged fields.
199func TestTaggedFieldDominates(t *testing.T) {

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…