Add MapMerge
This commit is contained in:
@@ -94,8 +94,6 @@ func TestStructToMapRecursive(t *testing.T) {
|
||||
default:
|
||||
t.Fatal("is not map")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func TestMapToStruct(t *testing.T) {
|
||||
@@ -267,7 +265,6 @@ func TestStructHasBsonName_False(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCopyMatching(t *testing.T) {
|
||||
|
||||
type O struct {
|
||||
Name string
|
||||
Age int
|
||||
@@ -293,5 +290,21 @@ func TestCopyMatching(t *testing.T) {
|
||||
if to.Name != "Nick" && to.Age != 15 && to.Active != true {
|
||||
t.Fatalf("Failed to copy matching fields to %v", to)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestMapMerge(t *testing.T) {
|
||||
m1 := map[string]any{
|
||||
"a": "va",
|
||||
"b": "vb",
|
||||
}
|
||||
m2 := map[string]any{
|
||||
"c": "vc",
|
||||
"d": "vd",
|
||||
}
|
||||
|
||||
m := MapMerge(m1, m2)
|
||||
|
||||
if len(m) != 4 {
|
||||
t.Fatalf("Merged map should have lenght 4 not %d", len(m))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user