goprotobuf: Fix proto.Merge handling of scalar bytes fields.
Previously the []byte would be treated as a repeated field,
and the new data would be appended. However, []byte is a
scalar field and the old data should be replaced instead.
Fixes #51.
LGTM=r
R=r
CC=golang-codereviews
https://codereview.appspot.com/91820043
diff --git a/proto/clone_test.go b/proto/clone_test.go
index 71343ea..39aaaf7 100644
--- a/proto/clone_test.go
+++ b/proto/clone_test.go
@@ -167,6 +167,12 @@
RepBytes: [][]byte{[]byte("sham"), []byte("wow")},
},
},
+ // Check that a scalar bytes field replaces rather than appends.
+ {
+ src: &pb.OtherMessage{Value: []byte("foo")},
+ dst: &pb.OtherMessage{Value: []byte("bar")},
+ want: &pb.OtherMessage{Value: []byte("foo")},
+ },
}
func TestMerge(t *testing.T) {