Sha256: f52dd24c5690dd95bff449fd1f93cc92bd003c454672ef6c7b34946f024665b5

Contents?: true

Size: 796 Bytes

Versions: 122

Compression:

Stored size: 796 Bytes

Contents

package hamming

import "testing"

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

122 entries across 122 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.179 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.178 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.177 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.176 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.175 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.174 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.173 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.172 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.171 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.170 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.169 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.167 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.166 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.165 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.164 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.163 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.162 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.161 tracks/go/exercises/hamming/hamming_test.go
trackler-2.2.1.160 tracks/go/exercises/hamming/hamming_test.go