(t *testing.T)
| 128 | } |
| 129 | |
| 130 | func TestJSONBuiltinEncoder(t *testing.T) { |
| 131 | var m runtime.JSONBuiltin |
| 132 | msg := &examplepb.SimpleMessage{ |
| 133 | Id: "foo", |
| 134 | } |
| 135 | |
| 136 | var buf bytes.Buffer |
| 137 | enc := m.NewEncoder(&buf) |
| 138 | if err := enc.Encode(msg); err != nil { |
| 139 | t.Errorf("enc.Encode(%v) failed with %v; want success", msg, err) |
| 140 | } |
| 141 | |
| 142 | got := new(examplepb.SimpleMessage) |
| 143 | if err := json.Unmarshal(buf.Bytes(), got); err != nil { |
| 144 | t.Errorf("json.Unmarshal(%q, got) failed with %v; want success", buf.String(), err) |
| 145 | } |
| 146 | if diff := cmp.Diff(got, msg, protocmp.Transform()); diff != "" { |
| 147 | t.Error(diff) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func TestJSONBuiltinEncoderFields(t *testing.T) { |
| 152 | var m runtime.JSONBuiltin |
nothing calls this directly
no test coverage detected