Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sum-of-multiples: Add test versioning #590

Merged
merged 1 commit into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions exercises/sum-of-multiples/example.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package summultiples

const testVersion = 1

// SumMultiples returns the sum of the multiples of the given divisors
// up to, but not including, the given limit.
func SumMultiples(limit int, divisors ...int) (sum int) {
Expand Down
8 changes: 8 additions & 0 deletions exercises/sum-of-multiples/sum_of_multiples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package summultiples

import "testing"

const targetTestVersion = 1

var varTests = []struct {
divisors []int
limit int
Expand All @@ -19,6 +21,12 @@ var varTests = []struct {
{[]int{}, 10000, 0},
}

func TestTestVersion(t *testing.T) {
if testVersion != targetTestVersion {
t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
}
}

func TestSumMultiples(t *testing.T) {
for _, test := range varTests {
s := SumMultiples(test.limit, test.divisors...)
Expand Down