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

Method TestAddressMap_Delete

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

Source from the content-addressed store, hash-verified

109}
110
111func (s) TestAddressMap_Delete(t *testing.T) {
112 addrMap := NewAddressMapV2[any]()
113 addrMap.Set(addr1, 1)
114 addrMap.Set(addr2, 2)
115 if got, want := addrMap.Len(), 2; got != want {
116 t.Fatalf("addrMap.Len() = %v; want %v", got, want)
117 }
118 addrMap.Delete(addr3)
119 addrMap.Delete(addr4)
120 addrMap.Delete(addr5)
121 addrMap.Delete(addr6)
122 addrMap.Delete(addr7) // aliases addr1
123 if got, ok := addrMap.Get(addr1); ok || got != nil {
124 t.Fatalf("addrMap.Get(addr1) = %v, %v; want nil, false", got, ok)
125 }
126 if got, ok := addrMap.Get(addr7); ok || got != nil {
127 t.Fatalf("addrMap.Get(addr7) = %v, %v; want nil, false", got, ok)
128 }
129 if got, ok := addrMap.Get(addr2); !ok || got.(int) != 2 {
130 t.Fatalf("addrMap.Get(addr2) = %v, %v; want %v, true", got, ok, 2)
131 }
132}
133
134func (s) TestAddressMap_Keys(t *testing.T) {
135 addrMap := NewAddressMapV2[int]()

Callers

nothing calls this directly

Calls 5

SetMethod · 0.65
LenMethod · 0.65
FatalfMethod · 0.65
GetMethod · 0.65
DeleteMethod · 0.45

Tested by

no test coverage detected