Sha256: 187859fa808ece6aa71ad3bf62e591b78a6d14a2be55a1e30fc0ba2fe139bc23

Contents?: true

Size: 1008 Bytes

Versions: 61

Compression:

Stored size: 1008 Bytes

Contents

package summultiples

import "testing"

const targetTestVersion = 1

var varTests = []struct {
	divisors []int
	limit    int
	sum      int
}{
	{[]int{3, 5}, 1, 0},
	{[]int{3, 5}, 4, 3},
	{[]int{3, 5}, 10, 23},
	{[]int{3, 5}, 100, 2318},
	{[]int{3, 5}, 1000, 233168},
	{[]int{7, 13, 17}, 20, 51},
	{[]int{43, 47}, 10000, 2203160},
	{[]int{5, 10, 12}, 10000, 13331672},
	{[]int{1, 1}, 10000, 49995000},
	{[]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...)
		if s != test.sum {
			t.Fatalf("Sum of multiples of %v to %d returned %d, want %d.",
				test.divisors, test.limit, s, test.sum)
		}
	}
}

func BenchmarkSumMultiples(b *testing.B) {
	for i := 0; i < b.N; i++ {
		for _, test := range varTests {
			SumMultiples(test.limit, test.divisors...)
		}
	}
}

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
trackler-2.1.0.26 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.25 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.24 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.23 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.22 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.21 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.20 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.19 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.18 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.17 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.16 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.15 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.14 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.13 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.12 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.11 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.10 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.9 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.8 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go
trackler-2.1.0.7 tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go