MCPcopy
hub / github.com/kubernetes/client-go / TestHeap_Get

Function TestHeap_Get

tools/cache/heap_test.go:253–270  ·  view source on GitHub ↗

TestHeap_Get tests Heap.Get.

(t *testing.T)

Source from the content-addressed store, hash-verified

251
252// TestHeap_Get tests Heap.Get.
253func TestHeap_Get(t *testing.T) {
254 h := NewHeap(testHeapObjectKeyFunc, compareInts)
255 h.Add(mkHeapObj("foo", 10))
256 h.Add(mkHeapObj("bar", 1))
257 h.Add(mkHeapObj("bal", 31))
258 h.Add(mkHeapObj("baz", 11))
259
260 // Get works with the key.
261 obj, exists, err := h.Get(mkHeapObj("baz", 0))
262 if err != nil || exists == false || obj.(testHeapObject).val != 11 {
263 t.Fatalf("unexpected error in getting element")
264 }
265 // Get non-existing object.
266 _, exists, err = h.Get(mkHeapObj("non-existing", 0))
267 if err != nil || exists == true {
268 t.Fatalf("didn't expect to get any object")
269 }
270}
271
272// TestHeap_GetByKey tests Heap.GetByKey and is very similar to TestHeap_Get.
273func TestHeap_GetByKey(t *testing.T) {

Callers

nothing calls this directly

Calls 4

AddMethod · 0.95
GetMethod · 0.95
NewHeapFunction · 0.85
mkHeapObjFunction · 0.85

Tested by

no test coverage detected