47 lines
526 B
Go
Executable File
47 lines
526 B
Go
Executable File
package utils
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestDeepSearch(t *testing.T) {
|
|
m := map[string]any{
|
|
"a": 1,
|
|
"b": map[string]any{
|
|
"c": 2,
|
|
},
|
|
}
|
|
|
|
mb := DeepSearch(m, []string{"b", "a"})
|
|
|
|
t.Log(m)
|
|
|
|
mb["cc"] = "3"
|
|
|
|
t.Log(m)
|
|
}
|
|
|
|
func TestMergeMap(t *testing.T) {
|
|
m1 := map[string]any{
|
|
"a": 1,
|
|
"b": map[string]any{
|
|
"c": 2,
|
|
"a": 1,
|
|
"b": map[string]any{
|
|
"c": 2,
|
|
"a": 1,
|
|
},
|
|
},
|
|
}
|
|
|
|
m2 := map[string]any{
|
|
"a": 11,
|
|
"b": map[string]any{
|
|
"c": 22,
|
|
"cc": 33,
|
|
},
|
|
}
|
|
|
|
t.Log(MergeMap(m1, m2))
|
|
}
|