Closed pascutto closed 4 years ago
Here's one for Uchar.t
let uchar : Uchar.t gen =
let c_gen : int gen =
choose [ range 0xD7FF
(* skip 0xD800..DFFF since they're reserved for UTF-16 encoding: *)
; map [range (*~min:0xE000 *) (0x10FFFF-0xE000)]
(fun x -> x+0xE000)]
in map [c_gen] Uchar.of_int
(* whole point of c_gen above was to able to use
Uchar.unsafe_of_int to avoid the bounds checking *)
(note that range ?min
would have avoided the extra map, but that was not available in my opam repo.)
Merged (eventually), thanks. I've added both the char
and uchar
generators (although with a slightly different implementation for uchar
)
This PR adds a
char : char gen
generator. While one can easily get it out of astring gen
usingmap
, I think it's nice to have basic types directly available.