go-by-test/roman/roman_test.go
2024-09-22 21:09:51 +02:00

35 lines
865 B
Go

package roman
import "testing"
func TestRomanNemerals(t *testing.T) {
cases := []struct {
Description string
Arabic int
Want string
}{
{"1 gets converted to I", 1, "I"},
{"2 gets converted to II", 2, "II"},
{"3 gets converted to III", 3, "III"},
{"4 gets converted to IV", 4, "IV"},
{"5 gets converted to V", 5, "V"},
{"7 gets converted to VII", 7, "VII"},
{"9 gets converted to IX", 9, "IX"},
{"10 gets converted to X", 10, "X"},
{"14 gets converted to XIV", 14, "XIV"},
{"18 gets converted to XVIII", 18, "XVIII"},
{"20 gets converted to XX", 20, "XX"},
{"39 gets converted to XXXIX", 39, "XXXIX"},
}
for _, test := range cases {
t.Run(test.Description, func(t *testing.T) {
got := ConvertToRoman(test.Arabic)
want := test.Want
if got != want {
t.Errorf("got %q, want %q", got, want)
}
})
}
}