Fix svnignore in the examples subdirectory.
[ocaml-bitstring.git] / tests / 06_ints1.ml
1 (* Extract some simple integers.
2  * $Id: 06_ints1.ml,v 1.2 2008-04-25 11:08:43 rjones Exp $
3  *)
4
5 let bits = Bitmatch.make_bitstring 16 '\xcf' (* makes the string 0xcfcf *)
6
7 let () =
8   bitmatch bits with
9   | { n0 : 4; n1 : 4; n2 : 4; n3 : 4;
10       rest : -1 : bitstring } ->
11       assert (n0 = 0xc);
12       assert (n1 = 0xf);
13       assert (n2 = 0xc);
14       assert (n3 = 0xf);
15
16       let _, off, len = rest in
17       assert (off = 16 && len = 0) (* no further data *)
18
19   | { _ } ->
20       failwith "error: did not match\n"