diff --git a/README.md b/README.md index 0f78b37..420d891 100644 --- a/README.md +++ b/README.md @@ -1 +1,21 @@ # Go Roman Numerals + +Convert to and from roman numerals in Go. + +```go +func ExampleToInt() { + integer, err := ToInt("IV") + if err != nil { + panic(err) + } + fmt.Println(integer == 4) +} + +func ExampleFromInt() { + roman, err := FromInt(4) + if err != nil { + panic(err) + } + fmt.Println(roman == "IV") +} +``` diff --git a/romannumeral_test.go b/romannumeral_test.go index 9e31b8d..d45cf72 100644 --- a/romannumeral_test.go +++ b/romannumeral_test.go @@ -1,6 +1,7 @@ package romannumeral import ( + "fmt" "testing" ) @@ -45,7 +46,7 @@ func TestFromInt(t *testing.T) { } } -func TestToInteger(t *testing.T) { +func TestToInt(t *testing.T) { for input, expected := range testCases { out, err := ToInt(input) if err != nil { @@ -72,3 +73,19 @@ func BenchmarkToInteger(b *testing.B) { _, _ = ToInt("DCCCXLIX") } } + +func ExampleToInt() { + integer, err := ToInt("IV") + if err != nil { + panic(err) + } + fmt.Println(integer == 4) +} + +func ExampleFromInt() { + roman, err := FromInt(4) + if err != nil { + panic(err) + } + fmt.Println(roman == "IV") +}