1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2022-11-18 16:53:59 +08:00
parent 6e24cf5bdc
commit b76be4ce6b
17 changed files with 103 additions and 180 deletions

27
mathx/int_test.go Normal file
View File

@ -0,0 +1,27 @@
package mathx_test
import (
"github.com/charlienet/go-mixed/mathx"
"github.com/stretchr/testify/assert"
"testing"
)
func TestMin(t *testing.T) {
assert.Equal(t, 1, mathx.Min(1, 3))
assert.Equal(t, 2, mathx.Min(66, 2))
}
func TestMax(t *testing.T) {
assert.Equal(t, 3, mathx.Max(1, 3))
assert.Equal(t, 66, mathx.Max(66, 2))
}
func TestAbs(t *testing.T) {
assert.Equal(t, 23, mathx.Abs1(23))
assert.Equal(t, 23, mathx.Abs1(-23))
assert.Equal(t, 0, mathx.Abs1(0))
var u int8 = -127
var exp int8 = 127
assert.Equal(t, exp, mathx.Abs1(u))
}