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,8 +5,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRomanNemerals(t *testing.T) {
|
||||
cases := []struct {
|
||||
var cases = []struct {
|
||||
Arabic int
|
||||
Roman string
|
||||
}{
|
||||
@ -40,6 +39,8 @@ func TestRomanNemerals(t *testing.T) {
|
||||
{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