Files
game-of-life/math/comp_test.go
Natercio Moniz ea5b5c4e75 Initial commit
implemented the game of life variation with hexagonal grid
2025-12-16 11:33:00 +00:00

76 lines
1.1 KiB
Go

package math
import (
"testing"
)
func TestMax(t *testing.T) {
testCases := []struct {
name string
values []int
exp int
}{
{
name: "multiple unique",
values: []int{3, 2, 4, 1},
exp: 4,
},
{
name: "single",
values: []int{5},
exp: 5,
},
{
name: "empty",
},
{
name: "multiple duplicates",
values: []int{2, 2, 2, 1},
exp: 2,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
act := Max(tc.values...)
if tc.exp != act {
t.Fatalf("want %v but got %v", tc.exp, act)
}
})
}
}
func TestMin(t *testing.T) {
testCases := []struct {
name string
values []int
exp int
}{
{
name: "multiple unique",
values: []int{3, 2, 4, 1},
exp: 1,
},
{
name: "single",
values: []int{5},
exp: 5,
},
{
name: "empty",
},
{
name: "multiple duplicates",
values: []int{2, 1, 1, 1},
exp: 1,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
act := Min(tc.values...)
if tc.exp != act {
t.Fatalf("want %v but got %v", tc.exp, act)
}
})
}
}