Write you some QuickCheck - Generating random characters
11 February 2016
This post is part of a series of posts on implementing a minimal version of QuickCheck from scratch. The source code is available on GitHub.
In the previous post I’ve generated random bytes. In this post, I’ll be generating random characters.
I’m going to need a couple of generators for this:
- one that picks numbers from the range (in HEX)
[20h..7Eh] for ASCII printable characters
[80h..FFh] for ASCII extended characters
- a generator that randomly uses one of the above generators
- a generator that applies a function (in this case
Operators.char<^T> to the above)
oneof depends on it
All the pieces are now in place, and so a char generator can be written as:
Finally, here are some sample characters: