summaryrefslogtreecommitdiff
path: root/roman_test.go
blob: 3bd96fcc533d94dd50cdbe7450aae9ed4f0be87c (plain)
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
package roman

import (
	"testing"
)

func TestRoman(t *testing.T) {
	testCases := []struct {
		r Roman
		s string
	}{
		{0, ""},
		{1666, "MDCLXVI"},
		{1990, "MCMXC"},
		{2008, "MMVIII"},
		{3888, "MMMDCCCLXXXVIII"},
		{3999, "MMMCMXCIX"},
	}
	for _, tc := range testCases {
		t.Run(tc.s, func(t *testing.T) {
			if tc.r.String() != tc.s {
				t.Errorf("got %v, want %v", tc.r, tc.s)
			}
		})
	}
}

func BenchmarkRoman(b *testing.B) {
	for i := 0; i < b.N; i++ {
		Roman(1666).String()
	}
}