github.com/micro/go-micro/v2@v2.9.1/util/qson/merge_test.go (about) 1 package qson 2 3 import "testing" 4 5 func TestMergeSlice(t *testing.T) { 6 a := []interface{}{"a"} 7 b := []interface{}{"b"} 8 actual := mergeSlice(a, b) 9 if len(actual) != 2 { 10 t.Errorf("Expected size to be 2.") 11 } 12 if actual[0] != "a" { 13 t.Errorf("Expected index 0 to have value a. Actual: %s", actual[0]) 14 } 15 if actual[1] != "b" { 16 t.Errorf("Expected index 1 to have value b. Actual: %s", actual[1]) 17 } 18 } 19 20 func TestMergeMap(t *testing.T) { 21 a := map[string]interface{}{ 22 "a": "b", 23 } 24 b := map[string]interface{}{ 25 "b": "c", 26 } 27 actual := mergeMap(a, b) 28 if len(actual) != 2 { 29 t.Errorf("Expected size to be 2.") 30 } 31 if actual["a"] != "b" { 32 t.Errorf("Expected key \"a\" to have value b. Actual: %s", actual["a"]) 33 } 34 if actual["b"] != "c" { 35 t.Errorf("Expected key \"b\" to have value c. Actual: %s", actual["b"]) 36 } 37 }