Initial commit
implemented the game of life variation with hexagonal grid
This commit is contained in:
75
math/comp_test.go
Normal file
75
math/comp_test.go
Normal file
@@ -0,0 +1,75 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user