Verify that absent required fields in groups cause Marshal/Unmarshal to return errors.
(t *testing.T)
| 1252 | |
| 1253 | // Verify that absent required fields in groups cause Marshal/Unmarshal to return errors. |
| 1254 | func TestRequiredFieldEnforcementGroups(t *testing.T) { |
| 1255 | pb := &pb2.GoTestRequiredGroupField{Group: &pb2.GoTestRequiredGroupField_Group{}} |
| 1256 | if _, err := proto.Marshal(pb); err == nil { |
| 1257 | t.Error("marshal: expected error, got nil") |
| 1258 | } else if !isRequiredNotSetError(err) { |
| 1259 | t.Errorf("marshal: bad error type: %v", err) |
| 1260 | } |
| 1261 | |
| 1262 | buf := []byte{11, 12} |
| 1263 | if err := proto.Unmarshal(buf, pb); err == nil { |
| 1264 | t.Error("unmarshal: expected error, got nil") |
| 1265 | } else if !isRequiredNotSetError(err) { |
| 1266 | t.Errorf("unmarshal: bad error type: %v", err) |
| 1267 | } |
| 1268 | } |
| 1269 | |
| 1270 | func TestTypedNilMarshal(t *testing.T) { |
| 1271 | // A typed nil should return ErrNil and not crash. |
nothing calls this directly
no test coverage detected