MCPcopy
hub / github.com/grpc/grpc-go / TestAddressMap_Keys

Method TestAddressMap_Keys

resolver/map_test.go:134–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

132}
133
134func (s) TestAddressMap_Keys(t *testing.T) {
135 addrMap := NewAddressMapV2[int]()
136 addrMap.Set(addr1, 1)
137 addrMap.Set(addr2, 2)
138 addrMap.Set(addr3, 3)
139 addrMap.Set(addr4, 4)
140 addrMap.Set(addr5, 5)
141 addrMap.Set(addr6, 6)
142 addrMap.Set(addr7, 7) // aliases addr1
143
144 want := []Address{addr1, addr2, addr3, addr4, addr5, addr6}
145 got := addrMap.Keys()
146 if d := cmp.Diff(want, got, cmp.Transformer("sort", func(in []Address) []Address {
147 out := append([]Address(nil), in...)
148 sort.Slice(out, func(i, j int) bool { return fmt.Sprint(out[i]) < fmt.Sprint(out[j]) })
149 return out
150 })); d != "" {
151 t.Fatalf("addrMap.Keys returned unexpected elements (-want, +got):\n%v", d)
152 }
153}
154
155func (s) TestAddressMap_Values(t *testing.T) {
156 addrMap := NewAddressMapV2[int]()

Callers

nothing calls this directly

Calls 4

SetMethod · 0.65
SliceMethod · 0.65
FatalfMethod · 0.65
KeysMethod · 0.45

Tested by

no test coverage detected