From fd9e8e787bea3bf813783cc20794596e648f7dd2 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Thu, 22 Aug 2024 12:58:53 +0200 Subject: [PATCH] Improve coverage --- src/fingerboard_location.ml | 14 +++++++++----- src/frequency.ml | 12 ++++++++++-- src/octave_designation.ml | 6 +++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/fingerboard_location.ml b/src/fingerboard_location.ml index 952fa80..92ffeb8 100644 --- a/src/fingerboard_location.ml +++ b/src/fingerboard_location.ml @@ -17,8 +17,12 @@ (* along with Fingerboard. If not, see . *) (**********************************************************************************) -type t = - { fingerboard_position : Fingerboard_position.t - ; string_number : Roman_numeral.t - } -[@@deriving compare, equal, hash, sexp_of] +include struct + [@@@coverage off] + + type t = + { fingerboard_position : Fingerboard_position.t + ; string_number : Roman_numeral.t + } + [@@deriving compare, equal, hash, sexp_of] +end diff --git a/src/frequency.ml b/src/frequency.ml index 09d26ce..deb7c5a 100644 --- a/src/frequency.ml +++ b/src/frequency.ml @@ -17,10 +17,18 @@ (* along with Fingerboard. If not, see . *) (**********************************************************************************) -type t = float [@@deriving compare, equal, hash, sexp_of] +include struct + [@@@coverage off] + + type t = float [@@deriving compare, equal, hash, sexp_of] +end + +let check_exn f = + if Float.compare f 0. < 0 then raise_s [%sexp "Out of bounds", [%here], (f : float)] +;; let of_float_exn f = - if Float.compare f 0. < 0 then raise_s [%sexp "Out of bounds", [%here], (f : float)]; + check_exn f; f ;; diff --git a/src/octave_designation.ml b/src/octave_designation.ml index a3c63fe..cb5f976 100644 --- a/src/octave_designation.ml +++ b/src/octave_designation.ml @@ -17,4 +17,8 @@ (* along with Fingerboard. If not, see . *) (**********************************************************************************) -type t = int [@@deriving compare, equal, hash, sexp_of] +include struct + [@@@coverage off] + + type t = int [@@deriving compare, equal, hash, sexp_of] +end