-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathroman_numerals_test.go
51 lines (45 loc) · 977 Bytes
/
roman_numerals_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package strings
import "testing"
/*
TestIntToRoman tests solution(s) with the following signature and problem description:
func IntToRoman(input int) string
Given a positive integer like return the equivalent inRoman numerals:
For example:
* Given 1, return I
* Given 4, return IV
* Given 5, return V
* Given 9, return IX
* Given 10, return X
* Given 40, return XL
* Given 50, return L
* Given 90, return XC
* Given 100, return C
* Given 400, return CD
* Given 500, return D
* Given 900, return CM
* Given 1000, return M
* Given 1917, return MCMXVII.
*/
func TestIntToRoman(t *testing.T) {
tests := []struct {
number int
roman string
}{
{0, ""},
{1, "I"},
{2, "II"},
{3, "III"},
{4, "IV"},
{5, "V"},
{6, "VI"},
{58, "LVIII"},
{60, "LX"},
{1000, "M"},
{1917, "MCMXVII"},
}
for i, test := range tests {
if got := IntToRoman(test.number); got != test.roman {
t.Fatalf("Failed test case #%d. Want %s got %s", i, test.roman, got)
}
}
}