permutation/permutation_test.go

52 lines
955 B
Go
Raw Normal View History

2022-01-21 21:12:47 +00:00
package permutation
import (
"testing"
)
2022-11-03 14:54:02 +00:00
func TestPermutations(t *testing.T) {
testCases := []struct {
name string
seed []int
permsExpected int
}{
{
"basic",
[]int{1, 2, 3},
6,
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
perms := Permutations(testCase.seed)
if len(perms) != testCase.permsExpected {
t.Errorf("len(perms) == %d, expected %d", len(perms), testCase.permsExpected)
}
})
}
}
func TestPermutationsAllSizes(t *testing.T) {
testCases := []struct {
name string
seed []int
permsExpected int
}{
{
"3 ints",
[]int{1, 2, 3},
15,
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
perms := PermutationsAllSizes(testCase.seed)
if len(perms) != testCase.permsExpected {
t.Errorf("len(perms) == %d, expected %d", len(perms), testCase.permsExpected)
}
})
}
2022-01-21 21:12:47 +00:00
}