Sha256: a61456948d024ef8533a669c55bfc9123b5aecfbf872815a6fc8ed39b849db48

Contents?: true

Size: 1006 Bytes

Versions: 122

Compression:

Stored size: 1006 Bytes

Contents

package trinary

import "testing"

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 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

122 entries across 122 versions & 1 rubygems

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