Files
codekata-golang/prime_factors_2021/prime_factors_test.go
VicRen ec56720802 prime factors 2021
I'm back
2021-08-26 17:33:59 +08:00

68 lines
714 B
Go

package main
import (
"reflect"
"testing"
)
func TestPrimeFactorsOf(t *testing.T) {
tt := []struct{
name string
input int
want []int
}{
{
"1",
1,
[]int{},
},
{
"2",
2,
[]int{2},
},
{
"3",
3,
[]int{3},
},
{
"4",
4,
[]int{2, 2},
},
{
"5",
5,
[]int{5},
},
{
"6",
6,
[]int{2, 3},
},
{
"7",
7,
[]int{7},
},
{
"8",
8,
[]int{2, 2, 2},
},
{
"9",
9,
[]int{3, 3},
},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
got := PrimeFactorsOf(tc.input)
if !reflect.DeepEqual(got, tc.want) {
t.Errorf("PrimeFactorsOf %d = %v, want %v", tc.input, got, tc.want)
}
})
}
}