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

Method TestEndpointMap_Length

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

Source from the content-addressed store, hash-verified

200}
201
202func (s) TestEndpointMap_Length(t *testing.T) {
203 em := NewEndpointMap[struct{}]()
204 // Should be empty at creation time.
205 if got := em.Len(); got != 0 {
206 t.Fatalf("em.Len() = %v; want 0", got)
207 }
208 // Add two endpoints with the same unordered set of addresses. This should
209 // amount to one endpoint. It should also not take into account attributes.
210 em.Set(endpoint12, struct{}{})
211 em.Set(endpoint21, struct{}{})
212
213 if got := em.Len(); got != 1 {
214 t.Fatalf("em.Len() = %v; want 1", got)
215 }
216
217 // Add another unique endpoint. This should cause the length to be 2.
218 em.Set(endpoint123, struct{}{})
219 if got := em.Len(); got != 2 {
220 t.Fatalf("em.Len() = %v; want 2", got)
221 }
222}
223
224func (s) TestEndpointMap_Get(t *testing.T) {
225 em := NewEndpointMap[int]()

Callers

nothing calls this directly

Calls 4

NewEndpointMapFunction · 0.85
LenMethod · 0.65
FatalfMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected