Sha256: 826e7c1c9e66f1cefab0398d2831cc81ee77219f7645bc8ae7bb63cc7cb48d17

Contents?: true

Size: 1.1 KB

Versions: 35

Compression:

Stored size: 1.1 KB

Contents

package transpose

import (
	"reflect"
	"testing"
)

const targetTestVersion = 1

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

func TestTranspose(t *testing.T) {
	for _, test := range testCases {
		actual := Transpose(test.input)
		if !reflect.DeepEqual(actual, test.expected) {
			// let's make the error more specific and find the row it's on
			min := min(len(test.expected), len(actual))
			for i := 0; i < min; i++ {
				if test.expected[i] != actual[i] {
					t.Fatalf("\n\tTranspose(%q): %s\n\n\tExpected: %q\n\tGot: %q\n\n\tRow %d Expected: %q Got: %q",
						test.input, test.description, test.expected, actual, i, test.expected[i], actual[i])
				}
			}
		}
	}
}

// helper function
// https://stackoverflow.com/questions/27516387/what-is-the-correct-way-to-find-the-min-between-two-integers-in-go
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func BenchmarkTranspose(b *testing.B) {
	for _, test := range testCases {
		for i := 0; i < b.N; i++ {
			Transpose(test.input)
		}
	}
}

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
trackler-2.1.0.0 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.55 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.54 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.53 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.52 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.51 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.50 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.49 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.48 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.47 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.46 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.45 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.44 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.43 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.42 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.41 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.40 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.39 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.38 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.37 tracks/go/exercises/transpose/transpose_test.go