Add file to testtool's correct submission test.
This commit is contained in:
parent
afe8fcdc4d
commit
ba90f2f10e
2 changed files with 16 additions and 1 deletions
|
@ -10,12 +10,13 @@ type testCase struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSum(t *testing.T) {
|
func TestSum(t *testing.T) {
|
||||||
|
s := &summer{}
|
||||||
for _, input := range []testCase{
|
for _, input := range []testCase{
|
||||||
{a: 2, b: 2, sum: 4},
|
{a: 2, b: 2, sum: 4},
|
||||||
{a: 2, b: -2, sum: 0},
|
{a: 2, b: -2, sum: 0},
|
||||||
{a: math.MaxInt64, b: 1, sum: math.MinInt64},
|
{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)
|
t.Errorf("%d + %d == %d != %d", input.a, input.b, out, input.sum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
tools/testtool/testdata/submissions/correct/sum/private/sum/summer.go
vendored
Normal file
14
tools/testtool/testdata/submissions/correct/sum/private/sum/summer.go
vendored
Normal 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)
|
||||||
|
}
|
Loading…
Reference in a new issue