diff options
Diffstat (limited to 'layout/math_test.go')
| -rw-r--r-- | layout/math_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/layout/math_test.go b/layout/math_test.go new file mode 100644 index 0000000..7ff6b78 --- /dev/null +++ b/layout/math_test.go @@ -0,0 +1,19 @@ +package layout + +import "testing" + +func TestSum(t *testing.T) { + t.Parallel() + testSum(t, []int{}, 0) + testSum(t, []int{0}, 0) + testSum(t, []int{1}, 1) + testSum(t, []int{12, 34}, 46) + testSum(t, []int{12, 34, 56}, 102) +} + +func testSum[N number](t *testing.T, s []N, want N) { + n := sum(s) + if n != want { + t.Errorf("sum(%v) = %v; want %v", s, n, want) + } +} |