roman: add property based test with quick.check
This commit is contained in:
parent
52825e49b3
commit
650ec27ec9
@ -3,6 +3,7 @@ package roman
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
"testing/quick"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cases = []struct {
|
var cases = []struct {
|
||||||
@ -65,3 +66,15 @@ func TestConvertingToArabic(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPropertiesOfConversion(t *testing.T) {
|
||||||
|
assertion := func(arabic int) bool {
|
||||||
|
roman := ConvertToRoman(arabic)
|
||||||
|
fromRoman := ConvertToArabic(roman)
|
||||||
|
return fromRoman == arabic
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := quick.Check(assertion, nil); err != nil {
|
||||||
|
t.Error("failed checks", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user