| 55 | } |
| 56 | |
| 57 | func TestDecodeRequiredFieldChecks(t *testing.T) { |
| 58 | for _, test := range testValidMessages { |
| 59 | if !test.partial { |
| 60 | continue |
| 61 | } |
| 62 | for _, m := range test.decodeTo { |
| 63 | t.Run(fmt.Sprintf("%s (%T)", test.desc, m), func(t *testing.T) { |
| 64 | opts := test.unmarshalOptions |
| 65 | opts.AllowPartial = false |
| 66 | got := reflect.New(reflect.TypeOf(m).Elem()).Interface().(proto.Message) |
| 67 | if err := proto.Unmarshal(test.wire, got); err == nil { |
| 68 | t.Fatalf("Unmarshal succeeded (want error)\nMessage:\n%v", prototext.Format(got)) |
| 69 | } |
| 70 | }) |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | func TestDecodeInvalidMessages(t *testing.T) { |
| 76 | for _, test := range testInvalidMessages { |