2016-03-30 02:51:37 +00:00
|
|
|
package lib_test
|
2016-02-12 07:58:48 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2016-03-30 02:51:37 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/consul/lib"
|
2016-02-12 07:58:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMathMaxInt(t *testing.T) {
|
|
|
|
tests := [][3]int{{1, 2, 2}, {-1, 1, 1}, {2, 0, 2}}
|
|
|
|
for i, _ := range tests {
|
|
|
|
expected := tests[i][2]
|
2016-03-30 02:51:37 +00:00
|
|
|
actual := lib.MaxInt(tests[i][0], tests[i][1])
|
2016-02-12 07:58:48 +00:00
|
|
|
if expected != actual {
|
|
|
|
t.Fatalf("in iteration %d expected %d, got %d", i, expected, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMathMinInt(t *testing.T) {
|
|
|
|
tests := [][3]int{{1, 2, 1}, {-1, 1, -1}, {2, 0, 0}}
|
|
|
|
for i, _ := range tests {
|
|
|
|
expected := tests[i][2]
|
2016-03-30 02:51:37 +00:00
|
|
|
actual := lib.MinInt(tests[i][0], tests[i][1])
|
2016-02-12 07:58:48 +00:00
|
|
|
if expected != actual {
|
|
|
|
t.Fatalf("in iteration %d expected %d, got %d", i, expected, actual)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|