Sha256: b27faaa5bd66ba445ce5c6b0b48ed951cb688133d8360a546a9e73d2d58a8e18

Contents?: true

Size: 1.11 KB

Versions: 116

Compression:

Stored size: 1.11 KB

Contents

package lsproduct

import "testing"

const targetTestVersion = 5

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

func TestLargestSeriesProduct(t *testing.T) {
	for _, test := range tests {
		p, err := LargestSeriesProduct(test.digits, test.span)
		if test.ok {
			// we do not expect error
			if err != nil {
				t.Fatalf("LargestSeriesProduct(%s, %d) returned error %q.  "+
					"Error not expected.",
					test.digits, test.span, err)
			}

			if int64(p) != test.product {
				t.Fatalf("LargestSeriesProduct(%s, %d) = %d, want %d",
					test.digits, test.span, p, test.product)
			}
		} else { // expect error
			// check if err is of error type
			var _ error = err

			// we expect error
			if err == nil {
				t.Fatalf("LargestSeriesProduct(%s, %d) = %d, %v."+
					"  Expected error got nil",
					test.digits, test.span, p, err)
			}
		}
	}
}

func BenchmarkLargestSeriesProduct(b *testing.B) {
	for i := 0; i < b.N; i++ {
		for _, test := range tests {
			LargestSeriesProduct(test.digits, test.span)
		}
	}
}

Version data entries

116 entries across 116 versions & 1 rubygems

Version Path
trackler-2.1.0.39 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.38 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.37 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.36 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.34 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.33 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.32 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.31 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.30 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.29 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.28 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.27 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.26 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.25 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.24 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.23 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.22 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.21 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.20 tracks/go/exercises/largest-series-product/largest_series_product_test.go
trackler-2.1.0.19 tracks/go/exercises/largest-series-product/largest_series_product_test.go