(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestSortedKeys(t *testing.T) { |
| 13 | t.Parallel() |
| 14 | |
| 15 | for idx, tc := range []struct { |
| 16 | name string |
| 17 | input map[string]int |
| 18 | expected []string |
| 19 | }{ |
| 20 | { |
| 21 | name: "SortsAlphabetically", |
| 22 | input: map[string]int{ |
| 23 | "banana": 1, |
| 24 | "apple": 2, |
| 25 | "cherry": 3, |
| 26 | }, |
| 27 | expected: []string{"apple", "banana", "cherry"}, |
| 28 | }, |
| 29 | { |
| 30 | name: "AlreadySorted", |
| 31 | input: map[string]int{ |
| 32 | "alpha": 1, |
| 33 | "mango": 2, |
| 34 | "zebra": 3, |
| 35 | }, |
| 36 | expected: []string{"alpha", "mango", "zebra"}, |
| 37 | }, |
| 38 | { |
| 39 | name: "EmptyMap", |
| 40 | input: map[string]int{}, |
| 41 | expected: nil, |
| 42 | }, |
| 43 | } { |
| 44 | t.Run("#"+strconv.Itoa(idx)+"_"+tc.name, func(t *testing.T) { |
| 45 | t.Parallel() |
| 46 | got := maps.SortedKeys(tc.input) |
| 47 | if diff := cmp.Diff(tc.expected, got); diff != "" { |
| 48 | t.Fatalf("unexpected result (-want +got):\n%s", diff) |
| 49 | } |
| 50 | }) |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | func TestSubset(t *testing.T) { |
| 55 | t.Parallel() |
nothing calls this directly
no test coverage detected