github.com/gogo/protobuf@v1.3.2/test/issue435/issue435pb_test.go (about) 1 package issue435 2 3 import ( 4 "testing" 5 6 proto "github.com/gogo/protobuf/proto" 7 ) 8 9 func TestNonnullableDefaults(t *testing.T) { 10 m := &Message{ 11 NonnullableOptional: SubMessage{}, 12 NonnullableRepeated: []SubMessage{{}}, 13 } 14 proto.SetDefaults(m) 15 16 if e, a := int64(7), *m.NonnullableOptional.Value; e != a { 17 t.Errorf("Default not set: want %d, got %d", e, a) 18 } 19 if e, a := int64(7), *m.NonnullableRepeated[0].Value; e != a { 20 t.Errorf("Default not set: want %d, got %d", e, a) 21 } 22 }