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

Method TestAddressMap_All

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

Source from the content-addressed store, hash-verified

171}
172
173func (s) TestAddressMap_All(t *testing.T) {
174 addrMap := NewAddressMapV2[int]()
175 addrMap.Set(addr1, 1)
176 addrMap.Set(addr2, 2)
177 addrMap.Set(addr3, 3)
178 addrMap.Set(addr4, 4)
179 addrMap.Set(addr5, 5)
180 addrMap.Set(addr6, 6)
181 addrMap.Set(addr7, 7) // aliases addr1
182
183 type pair struct {
184 K Address
185 V int
186 }
187
188 want := []pair{{addr1, 7}, {addr2, 2}, {addr3, 3}, {addr4, 4}, {addr5, 5}, {addr6, 6}}
189 var got []pair
190 for k, v := range addrMap.All() {
191 got = append(got, pair{k, v})
192 }
193 if d := cmp.Diff(want, got, cmp.Transformer("sort", func(in []pair) []pair {
194 out := append([]pair(nil), in...)
195 sort.Slice(out, func(i, j int) bool { return out[i].V < out[j].V })
196 return out
197 })); d != "" {
198 t.Fatalf("addrMap.All returned unexpected elements (-want, +got):\n%v", d)
199 }
200}
201
202func (s) TestEndpointMap_Length(t *testing.T) {
203 em := NewEndpointMap[struct{}]()

Callers

nothing calls this directly

Calls 4

SetMethod · 0.65
SliceMethod · 0.65
FatalfMethod · 0.65
AllMethod · 0.45

Tested by

no test coverage detected