Sha256: 496418a5be48c39d00f46c05b1e05436513cc063a2df4bd6f47f8791d45b8b1d

Contents?: true

Size: 935 Bytes

Versions: 51

Compression:

Stored size: 935 Bytes

Contents

package transpose

import (
	"reflect"
	"testing"
)

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

51 entries across 51 versions & 1 rubygems

Version Path
trackler-2.0.8.20 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.19 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.18 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.17 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.16 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.15 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.14 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.13 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.12 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.11 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.10 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.9 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.8 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.7 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.6 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.5 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.4 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.3 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.2 tracks/go/exercises/transpose/transpose_test.go
trackler-2.0.8.1 tracks/go/exercises/transpose/transpose_test.go