Sha256: 2cd09e4d470a7de5822776f402535e135e8fe63efe5a3ae44c9c054336b51ac7

Contents?: true

Size: 1.03 KB

Versions: 62

Compression:

Stored size: 1.03 KB

Contents

package secret

import (
	"reflect"
	"testing"
)

const targetTestVersion = 1

var tests = []struct {
	code uint
	h    []string
}{
	{1, []string{"wink"}},
	{2, []string{"double blink"}},
	{4, []string{"close your eyes"}},
	{8, []string{"jump"}},
	{3, []string{"wink", "double blink"}},
	{19, []string{"double blink", "wink"}},
	{31, []string{"jump", "close your eyes", "double blink", "wink"}},
	{0, nil},
	{32, nil},
	{33, []string{"wink"}},
}

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

func TestHandshake(t *testing.T) {
	for _, test := range tests {
		h := Handshake(test.code)
		// use len() to allow either nil or empty list, because
		// they are not equal by DeepEqual
		if len(h) == 0 && len(test.h) == 0 {
			continue
		}
		if !reflect.DeepEqual(h, test.h) {
			t.Fatalf("Handshake(%d) = %q, want %q.", test.code, h, test.h)
		}
	}
}

func BenchmarkHandshake(b *testing.B) {
	for i := 0; i < b.N; i++ {
		Handshake(31)
	}
}

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
trackler-2.1.0.27 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.26 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.25 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.24 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.23 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.22 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.21 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.20 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.19 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.18 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.17 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.16 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.15 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.14 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.13 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.12 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.11 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.10 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.9 tracks/go/exercises/secret-handshake/secret_handshake_test.go
trackler-2.1.0.8 tracks/go/exercises/secret-handshake/secret_handshake_test.go