You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
507 B
Go

package datastructures
import "testing"
func TestFactorial(t *testing.T) {
cases := []struct {
Name string
Input int
Expected int
}{
{
"Factorial of 5",
5,
120,
},
{
"Factorial of 10",
10,
3628800,
},
{
"Factorial of 12",
12,
479001600,
},
}
for _, test := range cases {
t.Run(test.Name, func(t *testing.T) {
got := Factorial(test.Input)
if got != test.Expected {
t.Errorf("Error got: %d want: %d", got, test.Expected)
}
})
}
}