mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-24 23:04:42 +01:00
47 lines
492 B
Go
47 lines
492 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestIsPrime(t *testing.T) {
|
|
tt := []struct {
|
|
name string
|
|
input int
|
|
want bool
|
|
}{
|
|
{
|
|
"1",
|
|
1,
|
|
false,
|
|
},
|
|
{
|
|
"2",
|
|
2,
|
|
true,
|
|
},
|
|
{
|
|
"10",
|
|
10,
|
|
false,
|
|
},
|
|
{
|
|
"17",
|
|
17,
|
|
true,
|
|
},
|
|
{
|
|
"97",
|
|
97,
|
|
true,
|
|
},
|
|
}
|
|
|
|
for _, tc := range tt {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
got := IsPrime(tc.input)
|
|
if got != tc.want {
|
|
t.Errorf("IsPrime(%d)=%v, want %v", tc.input, got, tc.want)
|
|
}
|
|
})
|
|
}
|
|
}
|