package sequence import ( "math" "testing" ) func TestMemorySequencerStopsAtTheLargestId(t *testing.T) { m := NewMemorySequencer() m.SetMax(math.MaxUint64) if id := m.NextFileId(1); id != math.MaxUint64 { t.Fatalf("after seeing the largest id the next one is %d", id) } m = NewMemorySequencer() m.SetMax(math.MaxUint64 - 2) if id := m.NextFileId(5); id != math.MaxUint64-1 { t.Fatalf("drew %d, want %d", id, uint64(math.MaxUint64-1)) } if id := m.NextFileId(1); id != math.MaxUint64 { t.Fatalf("the sequence wrapped back to %d", id) } }