Skip to content

Commit 4b49179

Browse files
authored
style: use consistent naming (TheAlgorithms#637)
* style: use consistent naming * style: use Int instead of Integer
1 parent b8648fb commit 4b49179

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed
File renamed without changes.
File renamed without changes.

conversion/romantointeger.go conversion/romantoint.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ var nums = []numeral{
3434
{1, "I"},
3535
}
3636

37-
// RomanToInteger converts a roman numeral string to an integer. Roman numerals for numbers
37+
// RomanToInt converts a roman numeral string to an integer. Roman numerals for numbers
3838
// outside the range 1 to 3,999 will return an error. Nil or empty string return 0
3939
// with no error thrown.
40-
func RomanToInteger(input string) (int, error) {
40+
func RomanToInt(input string) (int, error) {
4141
if input == "" {
4242
return 0, nil
4343
}

conversion/romantointeger_test.go conversion/romantoint_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@ var romanTestCases = map[string]int{
2121
"MMCMXCIX": 2999, "MMM": 3000, "MMMCMLXXIX": 3979, "MMMCMXCIX": 3999,
2222
}
2323

24-
func TestRomanToInteger(t *testing.T) {
24+
func TestRomanToInt(t *testing.T) {
2525
for input, expected := range romanTestCases {
26-
out, err := RomanToInteger(input)
26+
out, err := RomanToInt(input)
2727
if err != nil {
28-
t.Errorf("RomanToInteger(%s) returned an error %s", input, err.Error())
28+
t.Errorf("RomanToInt(%s) returned an error %s", input, err.Error())
2929
}
3030
if out != expected {
31-
t.Errorf("RomanToInteger(%s) = %d; want %d", input, out, expected)
31+
t.Errorf("RomanToInt(%s) = %d; want %d", input, out, expected)
3232
}
3333
}
34-
_, err := RomanToInteger("IVCMXCIX")
34+
_, err := RomanToInt("IVCMXCIX")
3535
if err == nil {
36-
t.Error("RomanToInteger(IVCMXCIX) expected an error")
36+
t.Error("RomanToInt(IVCMXCIX) expected an error")
3737
}
3838

39-
val, err := RomanToInteger("")
39+
val, err := RomanToInt("")
4040
if val != 0 {
41-
t.Errorf("RomanToInteger(\"\") = %d; want 0", val)
41+
t.Errorf("RomanToInt(\"\") = %d; want 0", val)
4242
}
4343
if err != nil {
44-
t.Errorf("RomanToInteger(\"\") returned an error %s", err.Error())
44+
t.Errorf("RomanToInt(\"\") returned an error %s", err.Error())
4545
}
4646
}
4747

48-
func BenchmarkRomanToInteger(b *testing.B) {
48+
func BenchmarkRomanToInt(b *testing.B) {
4949
b.ReportAllocs()
5050
for i := 0; i < b.N; i++ {
51-
_, _ = RomanToInteger("MMMCMXCIX")
51+
_, _ = RomanToInt("MMMCMXCIX")
5252
}
5353
}

0 commit comments

Comments
 (0)