permutation/permutation_test.go

52 lines
955 B
Go

package permutation
import (
"testing"
)
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)
}
})
}
}