-
-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathprime_test.go
More file actions
35 lines (30 loc) · 722 Bytes
/
Copy pathprime_test.go
File metadata and controls
35 lines (30 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package PrimalityTest
import (
"testing"
)
func TestIsPrimeNumber(t *testing.T) {
data := []struct {
n int
want bool
}{
{3, true}, {10, false}, {5, true}, {1024, false}, {29, true}, {7, true}, {11, true},
}
for _, d := range data {
if got := isPrimeNumber(d.n); got != d.want {
t.Errorf("Invalid value for N: %d, got: %t, want: %t", d.n, got, d.want)
}
}
}
func TestIsPrimeNumberUsingSqrt(t *testing.T) {
data := []struct {
n int
want bool
}{
{3, true}, {10, false}, {5, true}, {1024, false}, {29, true}, {7, true}, {11, true},
}
for _, d := range data {
if got := isPrime(d.n); got != d.want {
t.Errorf("Invalid value for N: %d, got: %t, want: %t", d.n, got, d.want)
}
}
}