-
-
Couldn't load subscription status.
- Fork 2.9k
Description
Even with MaxCount configured at 1000, it is technically possible that quick.Check passes values to our assertion function which fall outside of the range of [0, 3999]. In this case, due to the arabic > 3999 check in the assertion function, all of the tests would automatically pass and not catch any issues, making the test suite somewhat unreliable. This is even more apparent if you use a uint64 instead of a uint16.
To ensure that our property test is respecting the implicit restrictions of the ConvertToRoman and ConvertToArabic functions (which cannot accept or return a value greater than 3999, as called out in the book), it might be useful to inform readers about the Values property of quick.Config, as well, which can hardcode known "properties" (no pun intended) of a given implementation which cannot necessarily be represented with Go types and reflected automatically by the property testing library. For example, with the following config, we can guarantee that every test iteration in TestPropertiesOfConversion actually validates the implementation:
...
Values: func(args []reflect.Value, r *rand.Rand) {
args[0] = reflect.ValueOf(uint16(r.Intn(4000)))
},
...