MCPcopy
hub / github.com/golang/protobuf / TestProto1RepeatedGroup

Function TestProto1RepeatedGroup

proto/proto_test.go:1183–1203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1181}
1182
1183func TestProto1RepeatedGroup(t *testing.T) {
1184 pb := &pb2.MessageList{
1185 Message: []*pb2.MessageList_Message{
1186 {
1187 Name: proto.String("blah"),
1188 Count: proto.Int32(7),
1189 },
1190 // NOTE: pb.Message[1] is a nil
1191 nil,
1192 },
1193 }
1194
1195 o := new(proto.Buffer)
1196 err := o.Marshal(pb)
1197 if err == nil {
1198 t.Fatalf("expected error when marshaling repeted nil MessageList.Message")
1199 }
1200 if _, ok := err.(*proto.RequiredNotSetError); !ok {
1201 t.Fatalf("unexpected error when marshaling: %v", err)
1202 }
1203}
1204
1205// Test that enums work. Checks for a bug introduced by making enums
1206// named types instead of int32: newInt32FromUint64 would crash with

Callers

nothing calls this directly

Calls 3

StringFunction · 0.92
Int32Function · 0.92
MarshalMethod · 0.65

Tested by

no test coverage detected