File: math_test.go

package info (click to toggle)
git-lfs 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,808 kB
  • sloc: sh: 21,256; makefile: 507; ruby: 417
file content (27 lines) | stat: -rw-r--r-- 546 bytes parent folder | download | duplicates (2)
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))
}