• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mbarbin / vcs / 250

12 May 2025 07:57AM UTC coverage: 99.967% (-0.03%) from 100.0%
250

Pull #62

github

web-flow
Merge 00d1b9282 into 3de2267cb
Pull Request #62: Use fast bitvector

82 of 83 new or added lines in 3 files covered. (98.8%)

1 existing line in 1 file now uncovered.

3017 of 3018 relevant lines covered (99.97%)

36.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.65
/lib/vcs/test/test__bit_vector.ml
1
(*******************************************************************************)
2
(*  Vcs - a Versatile OCaml Library for Git Operations                         *)
3
(*  Copyright (C) 2024-2025 Mathieu Barbin <mathieu.barbin@gmail.com>          *)
4
(*                                                                             *)
5
(*  This file is part of Vcs.                                                  *)
6
(*                                                                             *)
7
(*  Vcs is free software; you can redistribute it and/or modify it under       *)
8
(*  the terms of the GNU Lesser General Public License as published by the     *)
9
(*  Free Software Foundation either version 3 of the License, or any later     *)
10
(*  version, with the LGPL-3.0 Linking Exception.                              *)
11
(*                                                                             *)
12
(*  Vcs is distributed in the hope that it will be useful, but WITHOUT ANY     *)
13
(*  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS  *)
14
(*  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License and    *)
15
(*  the file `NOTICE.md` at the root of this repository for more details.      *)
16
(*                                                                             *)
17
(*  You should have received a copy of the GNU Lesser General Public License   *)
18
(*  and the LGPL-3.0 Linking Exception along with this library. If not, see    *)
19
(*  <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively.       *)
20
(*******************************************************************************)
21

22
module Bit_vector = struct
23
  type t = Fast_bitvector.t
24

25
  let sexp_of_t = Fast_bitvector.sexp_of_t
26

27
  let create ~len value : t =
28
    let t = Fast_bitvector.create ~length:len in
3✔
29
    let () = if value then Fast_bitvector.set_all t in
2✔
30
    t
31
  ;;
32

33
  let length = Fast_bitvector.length
34
  let set = Fast_bitvector.set_to
35

36
  let reset t value =
NEW
UNCOV
37
    if value then Fast_bitvector.set_all t else Fast_bitvector.clear_all t
×
38
  ;;
39

40
  let intersect_in_place ~mutates other =
41
    if length mutates <> length other
3✔
42
    then invalid_arg "Bit_vector.intersect_in_place" [@coverage off];
43
    let (_ : Fast_bitvector.t) =
2✔
44
      Fast_bitvector.Set.intersect ~result:mutates mutates other
45
    in
46
    ()
2✔
47
  ;;
48
end
49

50
let%expect_test "intersect_in_place" =
51
  let v0 = Bit_vector.create ~len:10 true in
1✔
52
  print_s [%sexp (v0 : Bit_vector.t)];
1✔
53
  [%expect {| (LE 1111111111) |}];
1✔
54
  let v1 = Bit_vector.create ~len:10 false in
55
  print_s [%sexp (v1 : Bit_vector.t)];
1✔
56
  [%expect {| (LE 0000000000) |}];
1✔
57
  for i = 0 to Bit_vector.length v1 - 1 do
1✔
58
    if i % 2 = 0 then Bit_vector.set v1 i true
5✔
59
  done;
60
  Bit_vector.intersect_in_place ~mutates:v0 v1;
61
  print_s [%sexp (v0 : Bit_vector.t)];
1✔
62
  [%expect {| (LE 0101010101) |}];
1✔
63
  print_s [%sexp (v1 : Bit_vector.t)];
64
  [%expect {| (LE 0101010101) |}];
1✔
65
  Bit_vector.reset v1 false;
66
  for i = 0 to Bit_vector.length v1 - 1 do
1✔
67
    if i % 3 = 0 then Bit_vector.set v1 i true
4✔
68
  done;
69
  Bit_vector.intersect_in_place ~mutates:v0 v1;
70
  print_s [%sexp (v0 : Bit_vector.t)];
1✔
71
  [%expect {| (LE 0001000001) |}];
1✔
72
  print_s [%sexp (v1 : Bit_vector.t)];
73
  [%expect {| (LE 1001001001) |}];
1✔
74
  let vsmall = Bit_vector.create ~len:5 true in
75
  require_does_raise [%here] (fun () -> Bit_vector.intersect_in_place ~mutates:v0 vsmall);
1✔
76
  [%expect {| (Invalid_argument Bit_vector.intersect_in_place) |}];
1✔
77
  ()
78
;;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc