Skip to content

Commit be4efb6

Browse files
committed
✨ (roman_numerals): add fourth test and refactor
1 parent 28162b9 commit be4efb6

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

property-base-test/roman_number.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import "strings"
55
func ConvertToRoman(arabic int) string {
66
var result strings.Builder
77
for i := arabic; i > 0; i-- {
8+
if arabic == 4 {
9+
result.WriteString("IV")
10+
break
11+
}
812
result.WriteString("I")
913
}
1014
return result.String()

property-base-test/roman_number_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ func TestRomanNumerals(t *testing.T) {
1111
{"1 gets converted to I", 1, "I"},
1212
{"2 gets converted to II", 2, "II"},
1313
{"3 gets converted to III", 3, "III"},
14+
{"4 gets converted to IV", 4, "IV"},
1415
}
1516

1617
for _, test := range cases {

0 commit comments

Comments
 (0)