Sha256: eae3e96b7470c242ff46a6f7863c016b72f07f0671e2bd08c7175c440b876dbf

Contents?: true

Size: 1.24 KB

Versions: 81

Compression:

Stored size: 1.24 KB

Contents

package grains

import (
	"testing"
)

func TestSquare(t *testing.T) {
	for _, test := range squareTests {
		actualVal, actualErr := Square(test.input)

		// check actualVal only if no error expected
		if !test.expectError && actualVal != test.expectedVal {
			t.Fatalf("FAIL: %s\nSquare(%d) expected %d, Actual %d", test.description, test.input, test.expectedVal, actualVal)
		}

		// if we expect an error and there isn't one
		if test.expectError && actualErr == nil {
			t.Fatalf("FAIL: %s\nSquare(%d) expected an error, but error is nil", test.description, test.input)
		}
		// if we don't expect an error and there is one
		if !test.expectError && actualErr != nil {
			var _ error = actualErr
			t.Fatalf("FAIL: %s\nSquare(%d) expected no error, but error is: %s", test.description, test.input, actualErr)
		}
		t.Logf("PASS: %s", test.description)
	}
}

func TestTotal(t *testing.T) {
	var expected uint64 = 18446744073709551615
	if actual := Total(); actual != expected {
		t.Errorf("Total() expected %d, Actual %d", expected, actual)
	}
}

func BenchmarkSquare(b *testing.B) {

	for i := 0; i < b.N; i++ {

		for _, test := range squareTests {
			Square(test.input)
		}

	}
}

func BenchmarkTotal(b *testing.B) {
	for i := 0; i < b.N; i++ {
		Total()
	}
}

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.118 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.117 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.116 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.115 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.114 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.113 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.111 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.110 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.109 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.108 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.107 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.106 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.105 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.104 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.103 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.102 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.101 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.100 tracks/go/exercises/grains/grains_test.go
trackler-2.2.1.99 tracks/go/exercises/grains/grains_test.go