25 lines
328 B
Go
25 lines
328 B
Go
package num
|
|
|
|
import "testing"
|
|
|
|
type checklist struct {
|
|
n int
|
|
ret bool
|
|
}
|
|
|
|
func TestNum(t *testing.T) {
|
|
list := []checklist{
|
|
{2, true},
|
|
{3, true},
|
|
{4, false},
|
|
{57, false},
|
|
{97, true},
|
|
}
|
|
|
|
for _, item := range list {
|
|
if item.ret != IsPrime(item.n) {
|
|
t.Errorf("n: %v faild, want %v", item.n, item.ret)
|
|
}
|
|
}
|
|
}
|