File: 70_check_and_bind.ml

package info (click to toggle)
ocaml-bitstring 2.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,276 kB
  • ctags: 492
  • sloc: ml: 3,360; sh: 377; makefile: 324; ansic: 113
file content (17 lines) | stat: -rw-r--r-- 447 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(* Test check() and bind().
 * $Id: 70_check_and_bind.ml 142 2008-07-17 15:45:56Z richard.wm.jones $
 *)

open Printf
open Bitstring

let bits = (BITSTRING { 101 : 16; 202 : 16 })

let () =
  bitmatch bits with
  | { i : 16 : check (i = 101), bind (i*4);
      j : 16 : check (j = 202) } ->
      if i <> 404 || j <> 202 then
	failwith (sprintf "70_check_and_bind: failed: %d %d" i j)
  | { _ } ->
      failwith "70_check_and_bind: match failed"