@@ -187,12 +187,17 @@ func TestMerge(t *testing.T) {
187187 }, {
188188 src : & simple {},
189189 dest : & simple {Sa : 1 , Sb : "hello" , Sc : true , Sd : map [string ]string {"go" : "gogo" }, Se : nestS {Na : 22 }},
190- expected : & simple {Sa : 1 , Sb : "hello" , Sc : true , Sd : map [string ]string {"go" : "gogo" }, Se : nestS {Na : 22 }},
190+ expected : & simple {Sa : 0 , Sb : "hello" , Sc : false , Sd : map [string ]string {"go" : "gogo" }, Se : nestS {Na : 0 }},
191191 ok : true ,
192192 }, {
193193 src : & simple {Sa : 1 , Sc : true , Sd : map [string ]string {"go" : "gogo" }, Se : nestS {Na : 11 }, Sf : []string {"foo" }},
194- dest : & simple {Sa : 2 , Sb : "world" , Sc : false , Sd : map [string ]string {"go" : "old" }, Se : nestS {Na : 22 }, Sf : []string {"foo" }},
195- expected : & simple {Sa : 1 , Sb : "world" , Sc : true , Sd : map [string ]string {"go" : "gogo" }, Se : nestS {Na : 11 }, Sf : []string {"foo" , "foo" }},
194+ dest : & simple {Sa : 2 , Sb : "!" , Sc : false , Sd : map [string ]string {"go" : "old" }, Se : nestS {Na : 22 }, Sf : []string {"foo" }},
195+ expected : & simple {Sa : 1 , Sb : "!" , Sc : true , Sd : map [string ]string {"go" : "gogo" }, Se : nestS {Na : 11 }, Sf : []string {"foo" , "foo" }},
196+ ok : true ,
197+ }, {
198+ src : & simple {Sa : 0 , Sc : false , Sd : map [string ]string {"go" : "gogo" }, Se : nestS {Na : 11 }, Sf : []string {"foo" }},
199+ dest : & simple {Sa : 2 , Sb : "world" , Sc : true , Sd : map [string ]string {"go" : "old" }, Se : nestS {Na : 22 }, Sf : []string {"foo" }},
200+ expected : & simple {Sa : 0 , Sb : "world" , Sc : false , Sd : map [string ]string {"go" : "gogo" }, Se : nestS {Na : 11 }, Sf : []string {"foo" , "foo" }},
196201 ok : true ,
197202 }, {
198203 src : & simple {Sd : map [string ]string {"go" : "gogo" , "a" : "b" }},
@@ -204,6 +209,18 @@ func TestMerge(t *testing.T) {
204209 dest : & simple {},
205210 expected : & simple {Sd : map [string ]string {"go" : "gogo" , "a" : "b" }},
206211 ok : true ,
212+ }, {
213+ // empty map should not overwrite
214+ src : & simple {Sd : map [string ]string {}},
215+ dest : & simple {Sd : map [string ]string {"a" : "b" }},
216+ expected : & simple {Sd : map [string ]string {"a" : "b" }},
217+ ok : true ,
218+ }, {
219+ // empty slice should not overwrite
220+ src : & simple {Sf : []string {}},
221+ dest : & simple {Sf : []string {"c" }},
222+ expected : & simple {Sf : []string {"c" }},
223+ ok : true ,
207224 },
208225 } {
209226 err := Merge (tm .src , tm .dest )
0 commit comments