func TestIterEmpty(t *testing.T) {
	om := New(nil)
	it := itertools.NewIterator(om)
	assert.Panics(t, func() { it.Value() })
	assert.False(t, it.Next())
	it.Stop()
}
func TestNextAfterIterFinished(t *testing.T) {
	var pb PriorityBitmap
	pb.Set(0, 0)
	it := itertools.NewIterator(&pb)
	assert.True(t, it.Next())
	assert.False(t, it.Next())
	assert.False(t, it.Next())
}
Example #3
0
func TestEmptyBitmap(t *testing.T) {
	var bm Bitmap
	assert.False(t, bm.Contains(0))
	bm.Remove(0)
	it := itertools.NewIterator(&bm)
	assert.Panics(t, func() { it.Value() })
	assert.False(t, it.Next())
}
func TestRemoveWhileIterating(t *testing.T) {
	var pb PriorityBitmap
	pb.Set(0, 0)
	pb.Set(1, 1)
	it := itertools.NewIterator(&pb)
	go it.Stop()
	pb.Remove(0)
	time.Sleep(time.Millisecond)
	// This should return an empty list, as the iterator was stopped before
	// Next was called.
	assert.EqualValues(t, []interface{}(nil), itertools.IteratorAsSlice(it))
}
func TestEmpty(t *testing.T) {
	var pb PriorityBitmap
	it := itertools.NewIterator(&pb)
	assert.Panics(t, func() { it.Value() })
	assert.False(t, it.Next())
}