Add file to testtool's correct submission test.

This commit is contained in:
verytable 2020-01-31 23:49:50 +03:00
parent afe8fcdc4d
commit ba90f2f10e
2 changed files with 16 additions and 1 deletions

View file

@ -10,12 +10,13 @@ type testCase struct {
}
func TestSum(t *testing.T) {
s := &summer{}
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 {
if out := s.Sum(input.a, input.b); out != input.sum {
t.Errorf("%d + %d == %d != %d", input.a, input.b, out, input.sum)
}
}

View file

@ -0,0 +1,14 @@
// +build !change
package sum
type Summer interface {
Sum(a, b int64) int64
}
// Summer implementation.
type summer struct{}
func (s *summer) Sum(a, b int64) int64 {
return Sum(a, b)
}