mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-09-26 19:11:12 +08:00
33 lines
500 B
Go
33 lines
500 B
Go
package mathx
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestMin(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
input []int
|
|
expected int
|
|
}{
|
|
{
|
|
name: "空切片",
|
|
input: []int{},
|
|
expected: 0,
|
|
},
|
|
{
|
|
name: "普通切片",
|
|
input: []int{3, 7, 1, 9, 3, 0, 2, 2},
|
|
expected: 0,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
res := Min(tc.input)
|
|
assert.Equal(t, tc.expected, res)
|
|
})
|
|
}
|
|
}
|