shad-go/sum/sum_test.go
2020-01-19 01:59:27 +03:00

22 lines
385 B
Go

package sum
import (
"math"
"testing"
)
type testCase struct {
a, b, sum int64
}
func TestSum(t *testing.T) {
for _, input := range []testCase{
{a: 2, b: 2, sum: 4},
{a: 2, b: -2, sum: 0},
{a: math.MaxInt64, b: 1, sum: math.MinInt64},
} {
if out := Sum(input.a, input.b); out != input.sum {
t.Errorf("%d + %d == %d != %d", input.a, input.b, out, input.sum)
}
}
}