Add signed int extract and construction functions, and test.
[ocaml-bitstring.git] / t12_signed_bytes_limits.ml
1 let a = Array.init 387 (fun i -> i - 129)
2
3 let limits b =
4   Array.fold_left
5     (fun (mini,maxi) i ->
6        try 
7          ignore (b i);
8          (min mini i, max maxi i)
9        with 
10            _ -> (mini, maxi))
11     (0,0)
12     a
13
14 let () =
15   if
16     List.map limits [
17       (fun i -> BITSTRING { i : 2 : signed });
18       (fun i -> BITSTRING { i : 3 : signed });
19       (fun i -> BITSTRING { i : 4 : signed });
20       (fun i -> BITSTRING { i : 5 : signed });
21       (fun i -> BITSTRING { i : 6 : signed });
22       (fun i -> BITSTRING { i : 7 : signed });
23       (fun i -> BITSTRING { i : 8 : signed });
24     ]
25     <>
26       [
27         (-2, 3); 
28         (-4, 7); 
29         (-8, 15); 
30         (-16, 31); 
31         (-32, 63); 
32         (-64, 127); 
33         (-128, 255)
34       ]
35   then
36     failwith("t12_signed_bytes_limits: failed")