Sha256: 10d9343b740bd3ed4f53d63eeef002a874f8098deb70fcd7fce2fefa5b3dfeff
Contents?: true
Size: 1011 Bytes
Versions: 120
Compression:
Stored size: 1011 Bytes
Contents
package romannumerals import "testing" const targetTestVersion = 3 func TestRomanNumerals(t *testing.T) { if testVersion != targetTestVersion { t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion) } tc := append(romanNumeralTests, []romanNumeralTest{ {0, "", true}, {-1, "", true}, {4000, "", true}, {3999, "MMMCMXCIX", false}, }...) for _, test := range tc { actual, err := ToRomanNumeral(test.arabic) if err == nil && test.hasError { t.Errorf("ToRomanNumeral(%d) should return an error.", test.arabic) continue } if err != nil && !test.hasError { var _ error = err t.Errorf("ToRomanNumeral(%d) should not return an error.", test.arabic) continue } if !test.hasError && actual != test.roman { t.Errorf("ToRomanNumeral(%d): %s, expected %s", test.arabic, actual, test.roman) } } } func BenchmarkRomanNumerals(b *testing.B) { for i := 0; i < b.N; i++ { for _, test := range romanNumeralTests { ToRomanNumeral(test.arabic) } } }
Version data entries
120 entries across 120 versions & 1 rubygems