File: 31_bitstring_concat.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 (27 lines) | stat: -rw-r--r-- 554 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(* Test concat and the bit get functions.
 * $Id$
 *)

let () =
  for i = 0 to 33 do
    for j = 0 to 33 do
      for k = 0 to 33 do
	let bits =
	  Bitstring.concat [
	    Bitstring.ones_bitstring i;
	    Bitstring.zeroes_bitstring j;
	    Bitstring.ones_bitstring k
	  ] in
	assert (Bitstring.bitstring_length bits = i+j+k);
	for n = 0 to i-1 do
	  assert (Bitstring.is_set bits n)
	done;
	for n = i to i+j-1 do
	  assert (Bitstring.is_clear bits n)
	done;
	for n = i+j to i+j+k-1 do
	  assert (Bitstring.is_set bits n)
	done
      done
    done
  done