1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
package tools
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMinIntPicksTheSmallerInt(t *testing.T) {
assert.Equal(t, -1, MinInt(-1, 1))
}
func TestMaxIntPicksTheBiggertInt(t *testing.T) {
assert.Equal(t, 1, MaxInt(-1, 1))
}
func TestClampDiscardsIntsLowerThanMin(t *testing.T) {
assert.Equal(t, 0, ClampInt(-1, 0, 1))
}
func TestClampDiscardsIntsGreaterThanMax(t *testing.T) {
assert.Equal(t, 1, ClampInt(2, 0, 1))
}
func TestClampAcceptsIntsWithinBounds(t *testing.T) {
assert.Equal(t, 1, ClampInt(1, 0, 2))
}
|