Sha256: 2477786d5ca40d9c03cea2375386ebdcab8516b619d4813d338d725523ce667c

Contents?: true

Size: 986 Bytes

Versions: 96

Compression:

Stored size: 986 Bytes

Contents

package hamming

import "testing"

const targetTestVersion = 5

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

func TestHamming(t *testing.T) {
	for _, tc := range testCases {
		got, err := Distance(tc.s1, tc.s2)
		if tc.want < 0 {
			// check if err is of error type
			var _ error = err

			// we expect error
			if err == nil {
				t.Fatalf("Distance(%q, %q). error is nil.",
					tc.s1, tc.s2)
			}
		} else {
			if got != tc.want {
				t.Fatalf("Distance(%q, %q) = %d, want %d.",
					tc.s1, tc.s2, got, tc.want)
			}

			// we do not expect error
			if err != nil {
				t.Fatalf("Distance(%q, %q) returned error: %v when expecting none.",
					tc.s1, tc.s2, err)
			}
		}
	}
}

func BenchmarkHamming(b *testing.B) {
	// bench combined time to run through all test cases
	for i := 0; i < b.N; i++ {
		for _, tc := range testCases {
			Distance(tc.s1, tc.s2)
		}
	}
}

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
trackler-2.0.4.0 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.9 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.8 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.7 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.6 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.5 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.4 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.3 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.2 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.1 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.3.0 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.2.0 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.1.2 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.1.1 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.1.0 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.0.10 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.0.9 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.0.8 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.0.7 tracks/go/exercises/hamming/hamming_test.go
trackler-2.0.0.6 tracks/go/exercises/hamming/hamming_test.go