(t *testing.T, name string, f primalityTest)
| 11 | type primalityTest func(int64) bool |
| 12 | |
| 13 | func primalityTestTestingHelper(t *testing.T, name string, f primalityTest) { |
| 14 | arrayIndex := 0 |
| 15 | for i := 1; i <= testLimit; i++ { |
| 16 | isPrime := i == primeList[arrayIndex] |
| 17 | |
| 18 | testName := fmt.Sprintf("%s(%d)", name, i) |
| 19 | t.Run(testName, func(t *testing.T) { |
| 20 | result := f(int64(i)) |
| 21 | |
| 22 | if isPrime { |
| 23 | arrayIndex++ |
| 24 | } |
| 25 | |
| 26 | if result != isPrime { |
| 27 | t.Errorf("%d: %s function returned %v\n", i, name, result) |
| 28 | } |
| 29 | }) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | func primalityTestBenchmarkHelper(b *testing.B, f primalityTest) { |
| 34 | for i := 0; i < b.N; i++ { |
no outgoing calls
no test coverage detected