mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 21:35:52 +00:00
9fb64ab114
Based on work done by @fusiondog in #1583, extend the concept to use an integer instead of a boolean. Fixes: #1583 && #1481
28 lines
626 B
Go
28 lines
626 B
Go
package lib
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
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]
|
|
actual := MaxInt(tests[i][0], tests[i][1])
|
|
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]
|
|
actual := MinInt(tests[i][0], tests[i][1])
|
|
if expected != actual {
|
|
t.Fatalf("in iteration %d expected %d, got %d", i, expected, actual)
|
|
}
|
|
}
|
|
}
|