roman: add property based test with quick.check

This commit is contained in:
vinchent 2024-09-22 21:47:11 +02:00
parent 52825e49b3
commit 650ec27ec9

View File

@ -3,6 +3,7 @@ package roman
import (
"fmt"
"testing"
"testing/quick"
)
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)
}
}