Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9b72816

Browse files
Create roman-to-integer_test.go
1 parent 9547b86 commit 9b72816

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

‎roman-to-integer_test.go‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package leetcode_solutions_golang
2+
3+
import "testing"
4+
5+
func Test_romanToInt(t *testing.T) {
6+
type args struct {
7+
s string
8+
}
9+
tests := []struct {
10+
name string
11+
args args
12+
want int
13+
}{
14+
{
15+
name: "test case 1",
16+
args: args{
17+
s: "MCDXLIV",
18+
},
19+
want: 1444,
20+
},
21+
{
22+
name: "test case 2",
23+
args: args{
24+
s: "CMXCIX",
25+
},
26+
want: 999,
27+
},
28+
{
29+
name: "test case 3",
30+
args: args{
31+
s: "CXI",
32+
},
33+
want: 111,
34+
},
35+
}
36+
for _, tt := range tests {
37+
t.Run(tt.name, func(t *testing.T) {
38+
if got := romanToInt(tt.args.s); got != tt.want {
39+
t.Errorf("romanToInt() = %v, want %v", got, tt.want)
40+
}
41+
})
42+
}
43+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /