mirror of
https://github.com/cubixle/codekata-golang.git
synced 2026-04-30 14:58:44 +01:00
23: non-abundant sums
This commit is contained in:
@@ -2,19 +2,39 @@ package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestIsDivisibleFor1to20(t *testing.T) {
|
||||
func Test_isDivisible(t *testing.T) {
|
||||
tt := []struct {
|
||||
name string
|
||||
start int
|
||||
end int
|
||||
input int
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
"2",
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"10",
|
||||
1,
|
||||
10,
|
||||
2520,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"20",
|
||||
1,
|
||||
20,
|
||||
20,
|
||||
false,
|
||||
},
|
||||
{
|
||||
"14",
|
||||
1,
|
||||
20,
|
||||
14,
|
||||
false,
|
||||
},
|
||||
@@ -22,9 +42,9 @@ func TestIsDivisibleFor1to20(t *testing.T) {
|
||||
|
||||
for _, tc := range tt {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := IsDivisibleFor1to20(tc.input)
|
||||
got := IsDivisible(tc.start, tc.end, tc.input)
|
||||
if got != tc.want {
|
||||
t.Errorf("IsDivisibleFor1to20(%d)=%v, want %v", tc.input, got, tc.want)
|
||||
t.Errorf("IsDivisible(%d)=%v, want %v", tc.input, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user