github.com/frodejac/aoc-2022@v0.0.0-20221213081734-037c741b1c89/pkg/maptools/maptools_test.go (about) 1 package maptools 2 3 import "testing" 4 5 func TestMerge(t *testing.T) { 6 a := map[string]int{"a": 1, "b": 2} 7 b := map[string]int{"b": 3, "c": 4} 8 merged := Merge(a, b) 9 if merged["a"] != 1 { 10 t.Errorf("Expected merged[\"a\"] to be 1, got %d", merged["a"]) 11 } 12 if merged["b"] != 5 { 13 t.Errorf("Expected merged[\"b\"] to be 5, got %d", merged["b"]) 14 } 15 if merged["c"] != 4 { 16 t.Errorf("Expected merged[\"c\"] to be 4, got %d", merged["c"]) 17 } 18 } 19 20 func TestKeys(t *testing.T) { 21 a := map[string]int{"a": 1, "b": 2} 22 keys := Keys(a) 23 if len(keys) != 2 { 24 t.Errorf("Expected keys to be [\"a\", \"b\"], got %v", keys) 25 } 26 }