roman: add convert to arabic
This commit is contained in:
parent
6da23dc641
commit
715ea6477a
@ -35,3 +35,7 @@ func ConvertToRoman(arabic int) string {
|
||||
|
||||
return converted.String()
|
||||
}
|
||||
|
||||
func ConvertToArabic(roman string) int {
|
||||
return 1
|
||||
}
|
||||
|
@ -5,11 +5,10 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRomanNemerals(t *testing.T) {
|
||||
cases := []struct {
|
||||
var cases = []struct {
|
||||
Arabic int
|
||||
Roman string
|
||||
}{
|
||||
}{
|
||||
{Arabic: 1, Roman: "I"},
|
||||
{Arabic: 2, Roman: "II"},
|
||||
{Arabic: 3, Roman: "III"},
|
||||
@ -39,7 +38,9 @@ func TestRomanNemerals(t *testing.T) {
|
||||
{Arabic: 2014, Roman: "MMXIV"},
|
||||
{Arabic: 1006, Roman: "MVI"},
|
||||
{Arabic: 798, Roman: "DCCXCVIII"},
|
||||
}
|
||||
}
|
||||
|
||||
func TestRomanNemerals(t *testing.T) {
|
||||
for _, test := range cases {
|
||||
t.Run(fmt.Sprintf("%d gets converted to %q", test.Arabic, test.Roman), func(t *testing.T) {
|
||||
got := ConvertToRoman(test.Arabic)
|
||||
@ -51,3 +52,16 @@ func TestRomanNemerals(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConvertingToArabic(t *testing.T) {
|
||||
for _, test := range cases[:1] {
|
||||
t.Run(fmt.Sprintf("%q gets converted to %d", test.Roman, test.Arabic), func(t *testing.T) {
|
||||
got := ConvertToArabic(test.Roman)
|
||||
want := test.Arabic
|
||||
|
||||
if got != want {
|
||||
t.Errorf("got %d, want %d", got, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user