Beispiel #1
0
func t100(t *testing.T, pg prime.Generator) {
	if lim := pg.Limit(); lim < 100 {
		t.Errorf("%s Limit() returned %d.  result >= 100 expected.",
			reflect.TypeOf(pg), lim)
	}
	// Test boundary conditions and test results against known primes.
	k100 := []uint64{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,
		53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
	ti(t, pg, 0, 100, k100) // Iterate should handle 0 and 1 as min
	ti(t, pg, 1, 100, k100)
	ti(t, pg, 2, 100, k100)     // min = first prime, but 2 is often special
	ti(t, pg, 3, 100, k100[1:]) // min = first odd prime, still often special
	ti(t, pg, 4, 97, k100[2:])  // min = first composite, max is prime
	ti(t, pg, 5, 97, k100[2:])  // min = typical prime
}