186
186
t.Errorf("got %q, want %q", got, want)
192
type MyStruct struct {
196
func TestAnonymousNonstruct(t *testing.T) {
199
const want = `{"IntType":11}`
203
t.Fatalf("Marshal: %v", err)
205
if got := string(b); got != want {
206
t.Errorf("got %q, want %q", got, want)
223
// Legal Go: We never use the repeated embedded field (S).
231
func TestEmbeddedBug(t *testing.T) {
238
t.Fatal("Marshal:", err)
243
t.Fatalf("Marshal: got %s want %s", got, want)
245
// Now check that the duplicate field, S, does not appear.
251
t.Fatal("Marshal:", err)
256
t.Fatalf("Marshal: got %s want %s", got, want)
260
type BugD struct { // Same as BugA after tagging.
261
XXX string `json:"S"`
264
// BugD's tagged S field should dominate BugA's.
270
// Test that a field with a tag dominates untagged fields.
271
func TestTaggedFieldDominates(t *testing.T) {
278
t.Fatal("Marshal:", err)
280
want := `{"S":"BugD"}`
283
t.Fatalf("Marshal: got %s want %s", got, want)
287
// There are no tags here, so S should not appear.
291
BugY // Contains a tagged S field through BugD; should not dominate.
294
func TestDuplicatedFieldDisappears(t *testing.T) {
305
t.Fatal("Marshal:", err)
310
t.Fatalf("Marshal: got %s want %s", got, want)