MCPcopy
hub / github.com/cilium/cilium / TestPrefixMask

Function TestPrefixMask

pkg/allocator/allocator_test.go:282–299  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

280}
281
282func TestPrefixMask(t *testing.T) {
283 minID, maxID := idpool.ID(1), idpool.ID(5)
284 backend := newDummyBackend()
285 a, err := NewAllocator(hivetest.Logger(t), TestAllocatorKey(""), backend, WithMin(minID), WithMax(maxID), WithPrefixMask(1<<16))
286 require.NoError(t, err)
287 require.NotNil(t, a)
288
289 // allocate all available IDs
290 for i := minID; i <= maxID; i++ {
291 id, val, unmaskedID := a.selectAvailableID()
292 require.NotEqual(t, idpool.NoID, id)
293 require.Equal(t, idpool.ID(1), id>>16)
294 require.NotEqual(t, unmaskedID, id)
295 require.Equal(t, id.String(), val)
296 }
297
298 a.Delete()
299}
300
301func testAllocator(t *testing.T, maxID idpool.ID) {
302 backend := newDummyBackend()

Callers

nothing calls this directly

Calls 12

selectAvailableIDMethod · 0.95
DeleteMethod · 0.95
IDTypeAlias · 0.92
newDummyBackendFunction · 0.85
NewAllocatorFunction · 0.85
WithMinFunction · 0.85
WithMaxFunction · 0.85
WithPrefixMaskFunction · 0.85
TestAllocatorKeyTypeAlias · 0.70
LoggerMethod · 0.65
EqualMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…