added examples

This commit is contained in:
Branden
2021-02-07 15:19:37 -06:00
parent 676cdcecbe
commit ffcc16a44f
2 changed files with 38 additions and 1 deletions
+20
View File
@@ -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")
}
```
+18 -1
View File
@@ -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")
}