geom/primes/wheel_test.go

33 lines
766 B
Go

package primes
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWheelCantBeExpandedYet(t *testing.T) {
s := newWheel6(primes)
assert.Nil(t, s.expand())
}
func TestWheelIsExpanded(t *testing.T) {
s6 := newWheel6(primes)
s6.resetTo(419)
assert.Equal(t, 0, s6.offset)
s30 := s6.expand()
assert.EqualValues(t, []int64{2, 6, 4, 2, 4, 2, 4, 6}, s30.elements)
assert.EqualValues(t, []int64{2, 3, 5}, s30.primes)
assert.Equal(t, int64(30), s30.size)
assert.Equal(t, 0, s30.offset)
assert.Equal(t, s6.n, s30.n)
s210 := s30.expand()
assert.EqualValues(t, []int64{2, 3, 5, 7}, s210.primes)
assert.Equal(t, 48, len(s210.elements))
assert.Equal(t, int64(210), s210.size)
assert.Equal(t, 0, s210.offset)
assert.Equal(t, s30.n, s210.n)
}