|
|
@@ -195,6 +195,9 @@ var mergeTests = []struct {
|
|
|
NameMapping: map[int32]string{6: "Nigel"},
|
|
|
MsgMapping: map[int64]*pb.FloatingPoint{
|
|
|
0x4001: &pb.FloatingPoint{F: proto.Float64(2.0)},
|
|
|
+ 0x4002: &pb.FloatingPoint{
|
|
|
+ F: proto.Float64(2.0),
|
|
|
+ },
|
|
|
},
|
|
|
ByteMapping: map[bool][]byte{true: []byte("wowsa")},
|
|
|
},
|
|
|
@@ -203,6 +206,12 @@ var mergeTests = []struct {
|
|
|
6: "Bruce", // should be overwritten
|
|
|
7: "Andrew",
|
|
|
},
|
|
|
+ MsgMapping: map[int64]*pb.FloatingPoint{
|
|
|
+ 0x4002: &pb.FloatingPoint{
|
|
|
+ F: proto.Float64(3.0),
|
|
|
+ Exact: proto.Bool(true),
|
|
|
+ }, // the entire message should be overwritten
|
|
|
+ },
|
|
|
},
|
|
|
want: &pb.MessageWithMap{
|
|
|
NameMapping: map[int32]string{
|
|
|
@@ -211,6 +220,9 @@ var mergeTests = []struct {
|
|
|
},
|
|
|
MsgMapping: map[int64]*pb.FloatingPoint{
|
|
|
0x4001: &pb.FloatingPoint{F: proto.Float64(2.0)},
|
|
|
+ 0x4002: &pb.FloatingPoint{
|
|
|
+ F: proto.Float64(2.0),
|
|
|
+ },
|
|
|
},
|
|
|
ByteMapping: map[bool][]byte{true: []byte("wowsa")},
|
|
|
},
|
|
|
@@ -254,6 +266,27 @@ var mergeTests = []struct {
|
|
|
Union: &pb.Communique_Name{"Bobby Tables"},
|
|
|
},
|
|
|
},
|
|
|
+ {
|
|
|
+ src: &proto3pb.Message{
|
|
|
+ Terrain: map[string]*proto3pb.Nested{
|
|
|
+ "kay_a": &proto3pb.Nested{Cute: true}, // replace
|
|
|
+ "kay_b": &proto3pb.Nested{Bunny: "rabbit"}, // insert
|
|
|
+ },
|
|
|
+ },
|
|
|
+ dst: &proto3pb.Message{
|
|
|
+ Terrain: map[string]*proto3pb.Nested{
|
|
|
+ "kay_a": &proto3pb.Nested{Bunny: "lost"}, // replaced
|
|
|
+ "kay_c": &proto3pb.Nested{Bunny: "bunny"}, // keep
|
|
|
+ },
|
|
|
+ },
|
|
|
+ want: &proto3pb.Message{
|
|
|
+ Terrain: map[string]*proto3pb.Nested{
|
|
|
+ "kay_a": &proto3pb.Nested{Cute: true},
|
|
|
+ "kay_b": &proto3pb.Nested{Bunny: "rabbit"},
|
|
|
+ "kay_c": &proto3pb.Nested{Bunny: "bunny"},
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
func TestMerge(t *testing.T) {
|