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 = Bitmatch.Buffer.create () in
26 Bitmatch.construct_int64_be_unsigned bits i bitlen
27 (Failure "constructing string"))
29 let bits = Bitmatch.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 if Bitmatch.bitstring_length rest > 0 then
43 failwith (sprintf "loop failed with len = %d, bitlen = %d"
47 if actual <> expected then
48 failwith (sprintf "match bits: failed on 1 bit test, len = %d" len)