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

Function TestHeap_List

tools/cache/heap_test.go:307–335  ·  view source on GitHub ↗

TestHeap_List tests Heap.List function.

(t *testing.T)

Source from the content-addressed store, hash-verified

305
306// TestHeap_List tests Heap.List function.
307func TestHeap_List(t *testing.T) {
308 h := NewHeap(testHeapObjectKeyFunc, compareInts)
309 list := h.List()
310 if len(list) != 0 {
311 t.Errorf("expected an empty list")
312 }
313
314 items := map[string]int{
315 "foo": 10,
316 "bar": 1,
317 "bal": 30,
318 "baz": 11,
319 "faz": 30,
320 }
321 for k, v := range items {
322 h.Add(mkHeapObj(k, v))
323 }
324 list = h.List()
325 if len(list) != len(items) {
326 t.Errorf("expected %d items, got %d", len(items), len(list))
327 }
328 for _, obj := range list {
329 heapObj := obj.(testHeapObject)
330 v, ok := items[heapObj.name]
331 if !ok || v != heapObj.val {
332 t.Errorf("unexpected item in the list: %v", heapObj)
333 }
334 }
335}
336
337// TestHeap_ListKeys tests Heap.ListKeys function. Scenario is the same as
338// TestHeap_list.

Callers

nothing calls this directly

Calls 5

ListMethod · 0.95
AddMethod · 0.95
NewHeapFunction · 0.85
mkHeapObjFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected