Issue 5245.
(t *testing.T)
| 167 | |
| 168 | // Issue 5245. |
| 169 | func 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. |
| 199 | func TestTaggedFieldDominates(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…