Sha256: 79c6599c31d19b9a9a991f9cb5efe98f0bb6a7ee77aa2fa956928959c7d11af3
Contents?: true
Size: 1.31 KB
Versions: 167
Compression:
Stored size: 1.31 KB
Contents
package octal import ( "testing" ) const targetTestVersion = 1 var testCases = []struct { input string expectedNum int64 expectErr bool }{ {"1", 1, false}, {"10", 8, false}, {"1234567", 342391, false}, {"carrot", 0, true}, {"35682", 0, true}, } func TestTestVersion(t *testing.T) { if testVersion != targetTestVersion { t.Fatalf("Found testVersion = %v, want %v.", testVersion, targetTestVersion) } } func TestParseOctal(t *testing.T) { for _, test := range testCases { actualNum, actualErr := ParseOctal(test.input) // check actualNum only if no error expected if !test.expectErr && actualNum != test.expectedNum { t.Fatalf("ParseOctal(%s): expected[%d], actual [%d]", test.input, test.expectedNum, actualNum) } // if we expect an error and there isn't one if test.expectErr && actualErr == nil { t.Errorf("ParseOctal(%s): expected an error, but error is nil", test.input) } // if we don't expect an error and there is one if !test.expectErr && actualErr != nil { var _ error = actualErr t.Errorf("ParseOctal(%s): expected no error, but error is: %s", test.input, actualErr) } } } func BenchmarkParseOctal(b *testing.B) { b.StopTimer() for _, test := range testCases { b.StartTimer() for i := 0; i < b.N; i++ { ParseOctal(test.input) } b.StopTimer() } }
Version data entries
167 entries across 167 versions & 1 rubygems