Sha256: 78f5ce2f7bbabf756c51fa11ee60422c214ff89e40b130b180b2293bedf48415

Contents?: true

Size: 1.17 KB

Versions: 151

Compression:

Stored size: 1.17 KB

Contents

package trinary

import "testing"

const targetTestVersion = 1

var tests = []struct {
	arg  string
	want int64
	ok   bool
}{
	{"0", 0, true},
	{"1", 1, true},
	{"2", 2, true},
	{"10", 3, true},
	{"201", 19, true},
	{"0201", 19, true},
	{"0000000000000000000000000000000000000000201", 19, true},
	{"2021110011022210012102010021220101220221", 9223372036854775807, true},
	{"2021110011022210012102010021220101220222", 0, false},
}

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

func TestParseTrinary(t *testing.T) {
	for _, test := range tests {
		switch res, err := ParseTrinary(test.arg); {
		case err != nil:
			var _ error = err
			if test.ok {
				t.Errorf("ParseTrinary(%q) returned error %q, Error not expected",
					test.arg, err)
			}
		case !test.ok:
			t.Errorf("ParseTrinary(%q) = %d, %v, expected error", test.arg, res, err)
		case res != test.want:
			t.Errorf("ParseTrinary(%q) = %d, want %d", test.arg, res, test.want)
		}
	}
}

func BenchmarkParseTrinary(b *testing.B) {
	for i := 0; i < b.N; i++ {
		for _, test := range tests {
			ParseTrinary(test.arg)
		}
	}
}

Version data entries

151 entries across 151 versions & 1 rubygems

Version Path
trackler-2.2.1.56 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.55 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.54 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.53 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.52 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.51 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.50 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.49 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.48 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.47 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.46 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.45 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.44 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.43 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.42 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.41 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.40 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.39 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.38 tracks/go/exercises/trinary/trinary_test.go
trackler-2.2.1.37 tracks/go/exercises/trinary/trinary_test.go