1 (* Match random bits with integers.
17 for bitlen = 1 to 63 do
18 (* Create a random string of ints. *)
21 Random.int64 (Int64.sub (Int64.shift_left 1L bitlen) 1L))
24 let bits = Bitstring.Buffer.create () in
26 Bitstring.construct_int64_be_unsigned bits i bitlen
27 (Failure "constructing string"))
29 let bits = Bitstring.Buffer.contents bits in
31 (* Now read the bitstring as integers.
32 * In each case check the result against what we generated ('expected').
37 | { i : bitlen; rest : -1 : bitstring }
38 when Bitstring.bitstring_length rest = 0 -> [i]
39 | { i : bitlen; rest : -1 : bitstring } -> i :: loop rest
41 failwith (sprintf "loop failed with len = %d, bitlen = %d"
45 if actual <> expected then
46 failwith (sprintf "match ints: failed on test, len = %d, bitlen = %d"