File: math_test.go

package info (click to toggle)
git-lfs 3.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,880 kB
  • sloc: sh: 23,157; makefile: 519; ruby: 404
file content (19 lines) | stat: -rw-r--r-- 369 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package tools

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

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))
}