diff --git a/CHANGELOG.md b/CHANGELOG.md index cdefd0b5..c798cf16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ ## 0.20 +- add several new `bytes` combinators: + - `{QCheck,QCheck2}.Gen.{bytes_size,bytes,bytes_of,bytes_printable,bytes_small,bytes_small_of}` + - `QCheck.{Print,Shrink,Observable}.bytes` + - `QCheck2.{Print,Shrink}.bytes` + - `QCheck.{bytes_gen_of_size,bytes_of,bytes,bytes_small,bytes_small_of,bytes_of_size,bytes_printable}` +- add new `string` combinators and aliases: + - `{QCheck,QCheck2}.Gen.{string_small,string_small_of}` + - `QCheck.{string_small,string_small_of,string_of,string_printable,string_printable_of_size,string_small_printable,string_numeral,string_numeral_of_size}` +- `QCheck2.small_string` character generator argument is no more optional - add an optional argument with conservative default to `Shrink.string` - fix shrinkers in `QCheck.{printable_string,printable_string_of_size,small_printable_string,numeral_string,numeral_string_of_size}` [#257](https://github.com/c-cube/qcheck/issues/257) - add `QCheck2.Gen.set_shrink` to modify the generator's shrinker diff --git a/src/core/QCheck.ml b/src/core/QCheck.ml index ca267b69..aca834e8 100644 --- a/src/core/QCheck.ml +++ b/src/core/QCheck.ml @@ -365,19 +365,31 @@ module Gen = struct let printable st = printable_chars.[RS.int st (String.length printable_chars)] let numeral st = char_of_int (48 + RS.int st 10) - let string_size ?(gen = char) size st = + let bytes_size ?(gen = char) size st = let s = Bytes.create (size st) in for i = 0 to Bytes.length s - 1 do Bytes.set s i (gen st) done; + s + + let string_size ?(gen = char) size st = + let s = bytes_size ~gen size st in Bytes.unsafe_to_string s + + let bytes ?gen st = bytes_size ?gen nat st let string ?gen st = string_size ?gen nat st + let bytes_of gen = bytes_size ~gen nat let string_of gen = string_size ~gen nat + let bytes_printable = bytes_size ~gen:printable nat let string_printable = string_size ~gen:printable nat let string_readable = string_printable + let bytes_small st = bytes_size small_nat st + let bytes_small_of gen st = bytes_size ~gen small_nat st let small_string ?gen st = string_size ?gen small_nat st let small_list gen = list_size small_nat gen let small_array gen = array_size small_nat gen + let string_small st = string_size small_nat st + let string_small_of gen st = string_size ~gen small_nat st let join g st = (g st) st @@ -462,6 +474,7 @@ module Print = struct let int = string_of_int let bool = string_of_bool let float = string_of_float + let bytes = Bytes.to_string let string s = s let char c = String.make 1 c @@ -780,6 +793,8 @@ module Shrink = struct Buffer.clear buf; yield s) + let bytes ?(shrink = char) b = Iter.map Bytes.of_string (string ~shrink (Bytes.to_string b)) + let pair a b (x,y) yield = a x (fun x' -> yield (x',y)); b y (fun y' -> yield (x,y')) @@ -940,6 +955,7 @@ module Observable = struct let int i = i land max_int let bool b = if b then 1 else 2 let char x = Char.code x + let bytes (x:bytes) = Hashtbl.hash x let string (x:string) = Hashtbl.hash x let opt f = function | None -> 42 @@ -953,6 +969,7 @@ module Observable = struct type 'a t = 'a -> 'a -> bool let int : int t = (=) + let bytes : bytes t = (=) let string : string t = (=) let bool : bool t = (=) let float = Float.equal @@ -986,6 +1003,7 @@ module Observable = struct let bool : bool t = make ~hash:H.bool ~eq:Eq.bool Print.bool let int : int t = make ~hash:H.int ~eq:Eq.int Print.int let float : float t = make ~eq:Eq.float Print.float + let bytes = make ~hash:H.bytes ~eq:Eq.bytes Print.bytes let string = make ~hash:H.string ~eq:Eq.string Print.string let char = make ~hash:H.char ~eq:Eq.char Print.char @@ -1109,16 +1127,34 @@ let printable_char = let numeral_char = make ~print:(sprintf "%C") ~small:(small_char '0') ~shrink:Shrink.char_numeral Gen.numeral +let bytes_gen_of_size size gen = + make ~shrink:Shrink.bytes ~small:Bytes.length + ~print:(Print.bytes) (Gen.bytes_size ~gen size) +let bytes_of gen = + make ~shrink:Shrink.bytes ~small:Bytes.length + ~print:(Print.bytes) (Gen.bytes ~gen) + +let bytes = bytes_of Gen.char +let bytes_of_size size = bytes_gen_of_size size Gen.char +let bytes_small = bytes_gen_of_size Gen.small_nat Gen.char +let bytes_small_of gen = bytes_gen_of_size Gen.small_nat gen +let bytes_printable = + make ~shrink:(Shrink.bytes ~shrink:Shrink.char_printable) ~small:Bytes.length + ~print:(Print.bytes) (Gen.bytes ~gen:Gen.printable) + let string_gen_of_size size gen = make ~shrink:Shrink.string ~small:String.length ~print:(sprintf "%S") (Gen.string_size ~gen size) -let string_gen gen = +let string_of gen = make ~shrink:Shrink.string ~small:String.length ~print:(sprintf "%S") (Gen.string ~gen) -let string = string_gen Gen.char +let string = string_of Gen.char let string_of_size size = string_gen_of_size size Gen.char -let small_string = string_gen_of_size Gen.small_nat Gen.char +let string_small = string_gen_of_size Gen.small_nat Gen.char +let string_small_of gen = string_gen_of_size Gen.small_nat gen +let small_string = string_small +let string_gen = string_of let printable_string = make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length @@ -1140,6 +1176,12 @@ let numeral_string_of_size size = make ~shrink:(Shrink.string ~shrink:Shrink.char_numeral) ~small:String.length ~print:(sprintf "%S") (Gen.string_size ~gen:Gen.numeral size) +let string_printable = printable_string +let string_printable_of_size = printable_string_of_size +let string_small_printable = small_printable_string +let string_numeral = numeral_string +let string_numeral_of_size = numeral_string_of_size + let list_sum_ f l = List.fold_left (fun acc x-> f x+acc) 0 l let mk_list a gen = diff --git a/src/core/QCheck.mli b/src/core/QCheck.mli index 6e342c9f..d448999d 100644 --- a/src/core/QCheck.mli +++ b/src/core/QCheck.mli @@ -315,7 +315,7 @@ module Gen : sig (** All corner cases for int. @since 0.6 *) - val (--) : int -> int -> int t (** Synonym to {!int_range}. *) + val (--) : int -> int -> int t (** Synonym for {!int_range}. *) val ui32 : int32 t (** Generates (unsigned) [int32] values. *) @@ -397,6 +397,34 @@ module Gen : sig Example: [char_range 'a' 'z'] for all lower case ascii letters. @since 0.13 *) + val bytes_size : ?gen:char t -> int t -> bytes t + (** Builds a bytes generator from a (non-negative) size generator. + Accepts an optional character generator (the default is {!char}). + @since NEXT_RELEASE *) + + val bytes : ?gen:char t -> bytes t + (** Builds a bytes generator. Bytes size is generated by {!nat}. + Accepts an optional character generator (the default is {!char}). + See also {!bytes_of} and {!bytes_readable} for versions without + optional parameters. + @since NEXT_RELEASE *) + + val bytes_of : char t -> bytes t + (** Builds a bytes generator using the given character generator. + @since NEXT_RELEASE *) + + val bytes_printable : bytes t + (** Generator using the {!printable} character generator. + @since NEXT_RELEASE *) + + val bytes_small : bytes t + (** Builds a bytes generator using the {!char} character generator, length is {!small_nat} + @since NEXT_RELEASE *) + + val bytes_small_of : char t -> bytes t + (** Builds a bytes generator using the given character generator, length is {!small_nat}. + @since NEXT_RELEASE *) + val string_size : ?gen:char t -> int t -> string t (** Builds a string generator from a (non-negative) size generator. Accepts an optional character generator (the default is {!char}). *) @@ -425,6 +453,14 @@ module Gen : sig (** Builds a string generator, length is {!small_nat} Accepts an optional character generator (the default is {!char}). *) + val string_small : string t + (** Builds a string generator using the {!char} character generator, length is {!small_nat} + @since NEXT_RELEASE *) + + val string_small_of : char t -> string t + (** Builds a string generator using the given character generator, length is {!small_nat}. + @since NEXT_RELEASE *) + val small_list : 'a t -> 'a list t (** Generates lists of small size (see {!small_nat}). @since 0.5.3 *) @@ -577,6 +613,8 @@ module Print : sig val char : char t (** Character printer. *) + val bytes : bytes t (** Bytes printer. @since NEXT_RELEASE *) + val string : string t (** String printer. *) val option : 'a t -> 'a option t (** Option printer. *) @@ -645,7 +683,7 @@ module Iter : sig val map2 : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t val (>|=) : 'a t -> ('a -> 'b) -> 'b t val append : 'a t -> 'a t -> 'a t - val (<+>) : 'a t -> 'a t -> 'a t (** Synonym to {!append}. *) + val (<+>) : 'a t -> 'a t -> 'a t (** Synonym for {!append}. *) val of_list : 'a list -> 'a t val of_array : 'a array -> 'a t @@ -709,6 +747,9 @@ module Shrink : sig val option : 'a t -> 'a option t + val bytes : ?shrink:(char t) -> bytes t + (** @since NEXT_RELEASE *) + val string : ?shrink:(char t) -> string t val filter : ('a -> bool) -> 'a t -> 'a t @@ -811,6 +852,7 @@ module Observable : sig val int : int t val float : float t val string : string t + val bytes : bytes t (** @since NEXT_RELEASE *) val char : char t val make : @@ -1207,7 +1249,7 @@ val small_signed_int : int arbitrary @since 0.5.2 *) val (--) : int -> int -> int arbitrary -(** Synonym to {!int_range}. *) +(** Synonym for {!int_range}. *) val int32 : int32 arbitrary (** Int32 generator. Uniformly distributed. *) @@ -1241,12 +1283,46 @@ val printable_char : char arbitrary val numeral_char : char arbitrary (** Uniformly distributed over ['0'..'9']. *) +val bytes_gen_of_size : int Gen.t -> char Gen.t -> bytes arbitrary +(** Builds a bytes generator from a (non-negative) size generator and a character generator. + @since NEXT_RELEASE *) + +val bytes_of : char Gen.t -> bytes arbitrary +(** Generates bytes with a distribution of length of {!Gen.nat}. + @since NEXT_RELEASE *) + +val bytes : bytes arbitrary +(** Generates bytes with a distribution of length of {!Gen.nat} + and distribution of characters of [char]. + @since NEXT_RELEASE *) + +val bytes_small : bytes arbitrary +(** Same as {!bytes} but with a small length (ie {!Gen.small_nat} ). + @since NEXT_RELEASE *) + +val bytes_small_of : char Gen.t -> bytes arbitrary +(** Same as {!bytes_of} but with a small length (ie {!Gen.small_nat} ). + @since NEXT_RELEASE *) + +val bytes_of_size : int Gen.t -> bytes arbitrary +(** Generates bytes with distribution of characters of [char]. + @since NEXT_RELEASE *) + +val bytes_printable : bytes arbitrary +(** Generates bytes with a distribution of length of {!Gen.nat} + and distribution of characters of [printable_char]. + @since NEXT_RELEASE *) + val string_gen_of_size : int Gen.t -> char Gen.t -> string arbitrary (** Builds a string generator from a (non-negative) size generator and a character generator. *) val string_gen : char Gen.t -> string arbitrary (** Generates strings with a distribution of length of {!Gen.nat}. *) +val string_of : char Gen.t -> string arbitrary +(** Synonym for {!string_gen} added for convenience. + @since NEXT_RELEASE *) + val string : string arbitrary (** Generates strings with a distribution of length of {!Gen.nat} and distribution of characters of [char]. *) @@ -1254,6 +1330,14 @@ val string : string arbitrary val small_string : string arbitrary (** Same as {!string} but with a small length (ie {!Gen.small_nat} ). *) +val string_small : string arbitrary +(** Synonym for [small_string] added for convenience. + @since NEXT_RELEASE *) + +val string_small_of : char Gen.t -> string arbitrary +(** Same as {!string_of} but with a small length (ie {!Gen.small_nat} ). + @since NEXT_RELEASE *) + val small_list : 'a arbitrary -> 'a list arbitrary (** Generates lists of small size (see {!Gen.small_nat}). @since 0.5.3 *) @@ -1265,20 +1349,40 @@ val printable_string : string arbitrary (** Generates strings with a distribution of length of {!Gen.nat} and distribution of characters of [printable_char]. *) +val string_printable : string arbitrary +(** Synonym for [printable_string] added for convenience. + @since NEXT_RELEASE *) + val printable_string_of_size : int Gen.t -> string arbitrary (** Generates strings with distribution of characters of [printable_char]. *) +val string_printable_of_size : int Gen.t -> string arbitrary +(** Synonym for [printable_string_of_size] added for convenience. + @since NEXT_RELEASE *) + val small_printable_string : string arbitrary (** Generates strings with a length of [small_nat] and distribution of characters of [printable_char]. *) +val string_small_printable : string arbitrary +(** Synonym for [small_printable_string] added for convenience. + @since NEXT_RELEASE *) + val numeral_string : string arbitrary (** Generates strings with a distribution of length of {!Gen.nat} and distribution of characters of [numeral_char]. *) +val string_numeral : string arbitrary +(** Synonym for [numeral_string] added for convenience. + @since NEXT_RELEASE *) + val numeral_string_of_size : int Gen.t -> string arbitrary (** Generates strings with a distribution of characters of [numeral_char]. *) +val string_numeral_of_size : int Gen.t -> string arbitrary +(** Synonym for [numeral_string_of_size] added for convenience. + @since NEXT_RELEASE *) + val list : 'a arbitrary -> 'a list arbitrary (** Generates lists with length generated by {!Gen.nat}. *) diff --git a/src/core/QCheck2.ml b/src/core/QCheck2.ml index ec346577..2ab713db 100644 --- a/src/core/QCheck2.ml +++ b/src/core/QCheck2.ml @@ -698,13 +698,27 @@ module Gen = struct let string_size ?(gen = char) (size : int t) : string t = bytes_size ~gen size >|= Bytes.unsafe_to_string + let bytes : bytes t = bytes_size nat + + let bytes_of gen = bytes_size ~gen nat + + let bytes_printable = bytes_size ~gen:printable nat + + let bytes_small st = bytes_size small_nat st + + let bytes_small_of gen st = bytes_size ~gen small_nat st + let string : string t = string_size nat let string_of gen = string_size ~gen nat let string_printable = string_size ~gen:printable nat - let small_string ?gen st = string_size ?gen small_nat st + let string_small st = string_size small_nat st + + let string_small_of gen st = string_size ~gen small_nat st + + let small_string ~gen = string_small_of gen let small_list gen = list_size small_nat gen @@ -777,6 +791,8 @@ module Print = struct let float = string_of_float + let bytes = Bytes.to_string + let string s = Printf.sprintf "%S" s let char c = Printf.sprintf "%C" c @@ -962,6 +978,8 @@ module Observable = struct let char x = Char.code x + let bytes (x:bytes) = Hashtbl.hash x + let string (x:string) = Hashtbl.hash x let option f = function @@ -979,6 +997,8 @@ module Observable = struct let int : int t = (=) + let bytes : bytes t = (=) + let string : string t = (=) let bool : bool t = (=) @@ -1020,6 +1040,8 @@ module Observable = struct let float : float t = make ~eq:Eq.float Print.float + let bytes = make ~hash:H.bytes ~eq:Eq.bytes Print.bytes + let string = make ~hash:H.string ~eq:Eq.string Print.string let char = make ~hash:H.char ~eq:Eq.char Print.char @@ -1508,7 +1530,6 @@ module Test = struct let make_neg = make' ~negative:true let test_get_count (Test cell) = get_count cell - let test_get_long_factor (Test cell) = get_long_factor cell (** {6 Running the test} *) diff --git a/src/core/QCheck2.mli b/src/core/QCheck2.mli index f5810ea0..03d743d3 100644 --- a/src/core/QCheck2.mli +++ b/src/core/QCheck2.mli @@ -289,6 +289,51 @@ module Gen : sig Shrinks towards ['0']. *) + val bytes_size : ?gen:char t -> int t -> bytes t + (** Builds a bytes generator from a (non-negative) size generator. + Accepts an optional character generator (the default is {!char}). + + Shrinks on the number of characters first, then on the characters. + + @since NEXT_RELEASE *) + + val bytes : bytes t + (** Bytes generator using the {!char} character generator. Bytes size is generated by {!nat}. + See also {!bytes_of} and {!bytes_printable} for versions with + custom char generator. + + Shrinks on the number of characters first, then on the characters. + + @since NEXT_RELEASE *) + + val bytes_of : char t -> bytes t + (** Builds a bytes generator using the given character generator. + + Shrinks on the number of characters first, then on the characters. + + @since NEXT_RELEASE *) + + val bytes_printable : bytes t + (** Generator using the {!printable} character generator. + + Shrinks on the number of characters first, then on the characters. + + @since NEXT_RELEASE *) + + val bytes_small : bytes t + (** Builds a bytes generator using the {!char} character generator, length is {!small_nat}. + + Shrinks on the number of characters first, then on the characters. + + @since NEXT_RELEASE *) + + val bytes_small_of : char t -> bytes t + (** Builds a bytes generator using the given character generator, length is {!small_nat}. + + Shrinks on the number of characters first, then on the characters. + + @since NEXT_RELEASE *) + val string_size : ?gen:char t -> int t -> string t (** Builds a string generator from a (non-negative) size generator. Accepts an optional character generator (the default is {!char}). @@ -319,13 +364,25 @@ module Gen : sig @since 0.11 *) - val small_string : ?gen:char t -> string t - (** Builds a string generator, length is {!small_nat}. - Accepts an optional character generator (the default is {!char}). + val string_small : string t + (** Builds a string generator using the {!char} characher generator, length is {!small_nat}. + + Shrinks on the number of characters first, then on the characters. + + @since NEXT_RELEASE + *) + + val string_small_of : char t -> string t + (** Builds a string generator using the given characher generator, length is {!small_nat}. Shrinks on the number of characters first, then on the characters. + + @since NEXT_RELEASE *) + val small_string : gen:char t -> string t + (** alias for [string_small] for backward compatibility *) + val pure : 'a -> 'a t (** [pure a] creates a generator that always returns [a]. @@ -1036,6 +1093,10 @@ module Print : sig val char : char t (** [char] is a printer of character. *) + val bytes : bytes t + (** [bytes] is a printer of bytes. + @since NEXT_RELEASE *) + val string : string t (** [string] is a printer of string. *) @@ -1234,6 +1295,10 @@ module Observable : sig val float : float t (** [float] is an observable of [float]. *) + val bytes : bytes t + (** [bytes] is an observable of [bytes]. + @since NEXT_RELEASE *) + val string : string t (** [string] is an observable of [string]. *) @@ -1274,7 +1339,7 @@ module Observable : sig (** [quad o1 o2 o3 o4] is an observable of quadruples of [('a * 'b * 'c * 'd)]. *) end - + (** Utils on combining function arguments. *) module Tuple : sig (** Heterogeneous tuple, used to pass any number of arguments to diff --git a/test/core/QCheck2_expect_test.expected.32 b/test/core/QCheck2_expect_test.expected.32 index 4762e562..597728f6 100644 --- a/test/core/QCheck2_expect_test.expected.32 +++ b/test/core/QCheck2_expect_test.expected.32 @@ -282,6 +282,30 @@ Test printable never produces less than '5 failed (1 shrink steps): --- Failure -------------------------------------------------------------------- +Test bytes are empty failed (8 shrink steps): + +a + +--- Failure -------------------------------------------------------------------- + +Test bytes never has a \000 char failed (22 shrink steps): + +aaaaaaaaaaaaaaaaaaaaaa + +--- Failure -------------------------------------------------------------------- + +Test bytes never has a \255 char failed (59 shrink steps): + +aaaaaaaaaaaaaaaaaaaaaaaaaa˙aaaaaaaaaaaaaaaaaaaaaaaa + +--- Failure -------------------------------------------------------------------- + +Test bytes have unique chars failed (18 shrink steps): + +aaaaaaaaaaaaa + +--- Failure -------------------------------------------------------------------- + Test strings are empty failed (8 shrink steps): "a" @@ -504,6 +528,12 @@ Leaf 0 --- Failure -------------------------------------------------------------------- +Test sum list = 0 failed (0 shrink steps): + +[7; 1; 42; 1; 8; 5; 3; 9; 5; 38; 3; 3; 0; 1; 98; 1; 4; 13; 9; 2; 6; 9; 47; 6; 5; 8; 8; 6; 0; 9; 7; 2; 8; 6; 62; 6; 4; 31; 19; 1; 41; 60; 6; 5; 8; 1; 1; 4; 7; 7; 0; 5; 5; 71; 14; 26; 47; 5; 1; 6; 34; 9; 4; 2; 37; 3; 8; 4; 31; 6; 2; 1; 0; 7; 5; 1; 0; 15; 6; 1; 8; 13; 0; 6; 2; 4; 2; 6; 6; 1; 4; 1; 9; 79; 0; 87; 6; 8; 8; 62; 1; 4; 62; 6; 31; 1; 5; 6; 5; 9; 3; 3; 1; 79; 4; 3; 2; 67; 5; 7; 12; 70; 8; 8; 6; 1; 3; 14; 15; 1; 61; 4; 1; 4; 1; 7; 4; 4; 4; 2; 8; 8; 7; 5; 4; 27; 0; 9; 80; 25; 1; 8; 1; 3; 7; 4; 3; 5; 5; 6; 5; 5; 31; 7; 0; 3; 3; 6; 71; 76; 28; 60; 6; 2; 6; 3; 0; 4; 1; 0; 5; 7; 0; 28; 86; 4; 7; 51; 36; 0; 5; 0; 1; 4; 3; 6; 0; 1; 1; 8; 18; 4; 2; 8; 8; 1; 4; 7; 1; 0; 93; 5; 3; 0; 80; 1; 7; 7; 8; 8; 5; 7; 8; 9; 24; 4; 25; 8; 8; 5; 4; 90; 4; 6; 8; 4; 4; 0; 60; 8; 9; 7; 44; 5; 1; 2; 9; 74; 7; 7] + +--- Failure -------------------------------------------------------------------- + Test fail_pred_map_commute failed (37 shrink steps): ([1], {_ -> 0}, {0 -> false; 1 -> true; -489114431 -> false; -334037599 -> false; -1002044798 -> false; 3 -> false; 607479396 -> false; 4 -> false; 5 -> false; 442140485 -> false; 50542662 -> false; 38 -> false; 281414086 -> false; 757535206 -> false; 6 -> false; 7 -> false; 8 -> false; 629085609 -> false; 10 -> false; -765856245 -> false; 44 -> false; 12 -> false; -386873971 -> false; 15 -> false; 47 -> false; -842421617 -> false; 588710735 -> false; 49 -> false; 18 -> false; 51 -> false; 449695123 -> false; 20 -> false; 21 -> false; -386709771 -> false; -92591850 -> false; 136918038 -> false; 54 -> false; -484444937 -> false; -1042148456 -> false; 24 -> false; 1062551480 -> false; 747852089 -> false; 25 -> false; -737785766 -> false; 58 -> false; -530708612 -> false; -60654788 -> false; 28 -> false; 60 -> false; 29 -> false; 947455871 -> false; _ -> false}) @@ -645,6 +675,117 @@ stats depth: 14: # 7 15: 4 ++++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 + 5: ##################################################### 837 + 6: ##################################################### 826 + 7: ###################################################### 843 + 8: ####################################################### 855 + 9: #################################################### 813 + 10: ##################################################### 826 + ++++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 + 0.. 499: ####################################################### 4270 + 500.. 999: ###### 493 + 1000.. 1499: 16 + 1500.. 1999: 11 + 2000.. 2499: 15 + 2500.. 2999: 17 + 3000.. 3499: 11 + 3500.. 3999: 19 + 4000.. 4499: 14 + 4500.. 4999: 10 + 5000.. 5499: 16 + 5500.. 5999: 11 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 12 + 7500.. 7999: 16 + 8000.. 8499: 11 + 8500.. 8999: 4 + 9000.. 9499: 13 + 9500.. 9999: 13 + ++++ Stats for bytes_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 + 0.. 4: #################################################### 1925 + 5.. 9: ####################################################### 2005 + 10.. 14: # 52 + 15.. 19: # 50 + 20.. 24: # 55 + 25.. 29: # 56 + 30.. 34: # 55 + 35.. 39: # 49 + 40.. 44: # 65 + 45.. 49: # 65 + 50.. 54: # 55 + 55.. 59: # 68 + 60.. 64: # 61 + 65.. 69: # 65 + 70.. 74: # 57 + 75.. 79: # 66 + 80.. 84: # 65 + 85.. 89: # 64 + 90.. 94: # 60 + 95.. 99: # 62 + +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: @@ -1256,7 +1397,7 @@ stats dist: 966367653.. 1073741823: ################# 189 ================================================================================ 1 warning(s) -failure (59 tests failed, 3 tests errored, ran 130 tests) +failure (64 tests failed, 3 tests errored, ran 141 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/QCheck2_expect_test.expected.64 b/test/core/QCheck2_expect_test.expected.64 index 803bc65b..9854be8a 100644 --- a/test/core/QCheck2_expect_test.expected.64 +++ b/test/core/QCheck2_expect_test.expected.64 @@ -346,6 +346,30 @@ Test printable never produces less than '5 failed (1 shrink steps): --- Failure -------------------------------------------------------------------- +Test bytes are empty failed (8 shrink steps): + +a + +--- Failure -------------------------------------------------------------------- + +Test bytes never has a \000 char failed (22 shrink steps): + +aaaaaaaaaaaaaaaaaaaaaa + +--- Failure -------------------------------------------------------------------- + +Test bytes never has a \255 char failed (59 shrink steps): + +aaaaaaaaaaaaaaaaaaaaaaaaaa˙aaaaaaaaaaaaaaaaaaaaaaaa + +--- Failure -------------------------------------------------------------------- + +Test bytes have unique chars failed (18 shrink steps): + +aaaaaaaaaaaaa + +--- Failure -------------------------------------------------------------------- + Test strings are empty failed (8 shrink steps): "a" @@ -715,6 +739,117 @@ stats depth: 14: # 7 15: 4 ++++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 + 5: ##################################################### 837 + 6: ##################################################### 826 + 7: ###################################################### 843 + 8: ####################################################### 855 + 9: #################################################### 813 + 10: ##################################################### 826 + ++++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 + 0.. 499: ####################################################### 4270 + 500.. 999: ###### 493 + 1000.. 1499: 16 + 1500.. 1999: 11 + 2000.. 2499: 15 + 2500.. 2999: 17 + 3000.. 3499: 11 + 3500.. 3999: 19 + 4000.. 4499: 14 + 4500.. 4999: 10 + 5000.. 5499: 16 + 5500.. 5999: 11 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 12 + 7500.. 7999: 16 + 8000.. 8499: 11 + 8500.. 8999: 4 + 9000.. 9499: 13 + 9500.. 9999: 13 + ++++ Stats for bytes_printable len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 + 0.. 4: #################################################### 1925 + 5.. 9: ####################################################### 2005 + 10.. 14: # 52 + 15.. 19: # 50 + 20.. 24: # 55 + 25.. 29: # 56 + 30.. 34: # 55 + 35.. 39: # 49 + 40.. 44: # 65 + 45.. 49: # 65 + 50.. 54: # 55 + 55.. 59: # 68 + 60.. 64: # 61 + 65.. 69: # 65 + 70.. 74: # 57 + 75.. 79: # 66 + 80.. 84: # 65 + 85.. 89: # 64 + 90.. 94: # 60 + 95.. 99: # 62 + +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: @@ -1326,7 +1461,7 @@ stats dist: 4150517416584649600.. 4611686018427387903: ################# 189 ================================================================================ 1 warning(s) -failure (60 tests failed, 3 tests errored, ran 131 tests) +failure (64 tests failed, 3 tests errored, ran 141 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/QCheck2_tests.ml b/test/core/QCheck2_tests.ml index ab6c78fe..87b843ce 100644 --- a/test/core/QCheck2_tests.ml +++ b/test/core/QCheck2_tests.ml @@ -193,6 +193,15 @@ module Generator = struct Test.make ~name:"nat has right range" ~count:1000 ~print:Print.int Gen.nat (fun n -> 0 <= n && n < 10000) + let bytes_test = + Test.make ~name:"bytes has right length and content" ~count:1000 ~print:Print.bytes + Gen.bytes + (fun s -> + let len = Bytes.length s in + 0 <= len && len < 10000 + && Bytes.to_seq s |> + Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + let string_test = Test.make ~name:"string has right length and content" ~count:1000 ~print:Print.string Gen.string @@ -308,6 +317,7 @@ module Generator = struct char_dist_issue_23; char_test; nat_test; + bytes_test; string_test; pair_test; triple_test; @@ -386,6 +396,27 @@ module Shrink = struct Test.make ~name:"printable never produces less than '5" ~count:1000 ~print:Print.char Gen.numeral (fun c -> c >= '5') + let bytes_are_empty = + Test.make ~name:"bytes are empty" ~count:1000 ~print:Print.bytes + Gen.bytes (fun s -> s = Bytes.empty) + + let bytes_never_has_000_char = + Test.make ~name:"bytes never has a \\000 char" ~count:1000 ~print:Print.bytes + Gen.bytes + (fun s -> Bytes.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let bytes_never_has_255_char = + Test.make ~name:"bytes never has a \\255 char" ~count:1000 ~print:Print.bytes + Gen.bytes + (fun s -> Bytes.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) + + let bytes_unique_chars = + Test.make ~name:"bytes have unique chars" ~count:1000 ~print:Print.bytes + Gen.bytes + (fun s -> + let ch_list = Bytes.to_seq s |> List.of_seq in + List.length ch_list = List.length (List.sort_uniq Char.compare ch_list)) + let strings_are_empty = Test.make ~name:"strings are empty" ~count:1000 ~print:Print.string Gen.string (fun s -> s = "") @@ -604,6 +635,10 @@ module Shrink = struct char_is_never_abcdef; printable_is_never_sign; numeral_is_never_less_5; + bytes_are_empty; + bytes_never_has_000_char; + bytes_never_has_255_char; + bytes_unique_chars; strings_are_empty; string_never_has_000_char; string_never_has_255_char; @@ -776,6 +811,16 @@ module Stats = struct Test.make ~name:"numeral char code dist" ~count:500_000 ~stats:[("char code", Char.code)] Gen.numeral (fun _ -> true); ] + let bytes_len_tests = + let len = ("len",Bytes.length) in + [ + Test.make ~name:"bytes_size len dist" ~count:5_000 ~stats:[len] Gen.(bytes_size (int_range 5 10)) (fun _ -> true); + Test.make ~name:"bytes len dist" ~count:5_000 ~stats:[len] Gen.bytes (fun _ -> true); + Test.make ~name:"bytes_of len dist" ~count:5_000 ~stats:[len] Gen.(bytes_of (return 'a')) (fun _ -> true); + Test.make ~name:"bytes_printable len dist" ~count:5_000 ~stats:[len] Gen.bytes_printable (fun _ -> true); + Test.make ~name:"bytes_small len dist" ~count:5_000 ~stats:[len] Gen.(bytes_small_of char) (fun _ -> true); + ] + let string_len_tests = let len = ("len",String.length) in [ @@ -850,6 +895,7 @@ module Stats = struct [ bool_dist; ] @ char_dist_tests @ [ tree_depth_test;] + @ bytes_len_tests @ string_len_tests @ [pair_dist; triple_dist; diff --git a/test/core/QCheck_expect_test.expected.32 b/test/core/QCheck_expect_test.expected.32 index de696d1f..50d79b29 100644 --- a/test/core/QCheck_expect_test.expected.32 +++ b/test/core/QCheck_expect_test.expected.32 @@ -252,6 +252,30 @@ Test printable never produces less than '5 failed (3 shrink steps): --- Failure -------------------------------------------------------------------- +Test bytes are empty failed (15 shrink steps): + +a + +--- Failure -------------------------------------------------------------------- + +Test bytes never has a \000 char failed (8 shrink steps): + + + +--- Failure -------------------------------------------------------------------- + +Test bytes never has a \255 char failed (14 shrink steps): + +˙ + +--- Failure -------------------------------------------------------------------- + +Test bytes have unique chars failed (13 shrink steps): + + + +--- Failure -------------------------------------------------------------------- + Test strings are empty failed (15 shrink steps): "a" @@ -641,6 +665,92 @@ stats dist: 19: ################################################## 253 20: ############################################## 230 ++++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 + 5: ##################################################### 837 + 6: ##################################################### 826 + 7: ###################################################### 843 + 8: ####################################################### 855 + 9: #################################################### 813 + 10: ##################################################### 826 + ++++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 + 0.. 499: ####################################################### 4270 + 500.. 999: ###### 493 + 1000.. 1499: 16 + 1500.. 1999: 11 + 2000.. 2499: 15 + 2500.. 2999: 17 + 3000.. 3499: 11 + 3500.. 3999: 19 + 4000.. 4499: 14 + 4500.. 4999: 10 + 5000.. 5499: 16 + 5500.. 5999: 11 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 12 + 7500.. 7999: 16 + 8000.. 8499: 11 + 8500.. 8999: 4 + 9000.. 9499: 13 + 9500.. 9999: 13 + ++++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 + 0.. 4: #################################################### 1925 + 5.. 9: ####################################################### 2005 + 10.. 14: # 52 + 15.. 19: # 50 + 20.. 24: # 55 + 25.. 29: # 56 + 30.. 34: # 55 + 35.. 39: # 49 + 40.. 44: # 65 + 45.. 49: # 65 + 50.. 54: # 55 + 55.. 59: # 68 + 60.. 64: # 61 + 65.. 69: # 65 + 70.. 74: # 57 + 75.. 79: # 66 + 80.. 84: # 65 + 85.. 89: # 64 + 90.. 94: # 60 + 95.. 99: # 62 + +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: @@ -1252,7 +1362,7 @@ stats dist: 966367653.. 1073741823: ################# 189 ================================================================================ 1 warning(s) -failure (59 tests failed, 3 tests errored, ran 139 tests) +failure (63 tests failed, 3 tests errored, ran 148 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/QCheck_expect_test.expected.64 b/test/core/QCheck_expect_test.expected.64 index e6a4e83b..26cb5722 100644 --- a/test/core/QCheck_expect_test.expected.64 +++ b/test/core/QCheck_expect_test.expected.64 @@ -284,6 +284,30 @@ Test printable never produces less than '5 failed (3 shrink steps): --- Failure -------------------------------------------------------------------- +Test bytes are empty failed (15 shrink steps): + +a + +--- Failure -------------------------------------------------------------------- + +Test bytes never has a \000 char failed (8 shrink steps): + + + +--- Failure -------------------------------------------------------------------- + +Test bytes never has a \255 char failed (14 shrink steps): + +˙ + +--- Failure -------------------------------------------------------------------- + +Test bytes have unique chars failed (13 shrink steps): + + + +--- Failure -------------------------------------------------------------------- + Test strings are empty failed (15 shrink steps): "a" @@ -673,6 +697,92 @@ stats dist: 19: ################################################## 253 20: ############################################## 230 ++++ Stats for bytes_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 7.49, stddev: 1.70, median 7, min 5, max 10 + 5: ##################################################### 837 + 6: ##################################################### 826 + 7: ###################################################### 843 + 8: ####################################################### 855 + 9: #################################################### 813 + 10: ##################################################### 826 + ++++ Stats for bytes len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 384.53, stddev: 1330.61, median 9, min 0, max 9969 + 0.. 498: ####################################################### 4246 + 499.. 997: ###### 518 + 998..1496: 21 + 1497..1995: 10 + 1996..2494: 11 + 2495..2993: 10 + 2994..3492: 13 + 3493..3991: 13 + 3992..4490: 5 + 4491..4989: 10 + 4990..5488: 19 + 5489..5987: 9 + 5988..6486: 10 + 6487..6985: 12 + 6986..7484: 17 + 7485..7983: 16 + 7984..8482: 16 + 8483..8981: 16 + 8982..9480: 16 + 9481..9979: 12 + ++++ Stats for bytes_of len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 363.14, stddev: 1245.80, median 9, min 0, max 9986 + 0.. 499: ####################################################### 4270 + 500.. 999: ###### 493 + 1000.. 1499: 16 + 1500.. 1999: 11 + 2000.. 2499: 15 + 2500.. 2999: 17 + 3000.. 3499: 11 + 3500.. 3999: 19 + 4000.. 4499: 14 + 4500.. 4999: 10 + 5000.. 5499: 16 + 5500.. 5999: 11 + 6000.. 6499: 15 + 6500.. 6999: 13 + 7000.. 7499: 12 + 7500.. 7999: 16 + 8000.. 8499: 11 + 8500.. 8999: 4 + 9000.. 9499: 13 + 9500.. 9999: 13 + ++++ Stats for bytes_small len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +stats len: + num: 5000, avg: 15.57, stddev: 24.36, median 6, min 0, max 99 + 0.. 4: #################################################### 1925 + 5.. 9: ####################################################### 2005 + 10.. 14: # 52 + 15.. 19: # 50 + 20.. 24: # 55 + 25.. 29: # 56 + 30.. 34: # 55 + 35.. 39: # 49 + 40.. 44: # 65 + 45.. 49: # 65 + 50.. 54: # 55 + 55.. 59: # 68 + 60.. 64: # 61 + 65.. 69: # 65 + 70.. 74: # 57 + 75.. 79: # 66 + 80.. 84: # 65 + 85.. 89: # 64 + 90.. 94: # 60 + 95.. 99: # 62 + +++ Stats for string_size len dist ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ stats len: @@ -1284,7 +1394,7 @@ stats dist: 4150517416584649600.. 4611686018427387903: ################# 189 ================================================================================ 1 warning(s) -failure (59 tests failed, 3 tests errored, ran 139 tests) +failure (63 tests failed, 3 tests errored, ran 148 tests) random seed: 153870556 +++ Stats for int_dist_empty_bucket ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/test/core/QCheck_tests.ml b/test/core/QCheck_tests.ml index 0b26559c..7d22045b 100644 --- a/test/core/QCheck_tests.ml +++ b/test/core/QCheck_tests.ml @@ -201,6 +201,15 @@ module Generator = struct Test.make ~name:"nat has right range" ~count:1000 (make ~print:Print.int Gen.nat) (fun n -> 0 <= n && n < 10000) + let bytes_test = + Test.make ~name:"bytes has right length and content" ~count:1000 + bytes + (fun b -> + let len = Bytes.length b in + 0 <= len && len < 10000 + && Bytes.to_seq b |> + Seq.fold_left (fun acc c -> acc && '\000' <= c && c <= '\255') true) + let string_test = Test.make ~name:"string has right length and content" ~count:1000 string @@ -389,6 +398,7 @@ module Generator = struct printable_test; numeral_test; nat_test; + bytes_test; string_test; pair_test; triple_test; @@ -471,6 +481,26 @@ module Shrink = struct let numeral_is_never_less_5 = Test.make ~name:"printable never produces less than '5" ~count:1000 numeral_char (fun c -> c >= '5') + let bytes_are_empty = + Test.make ~name:"bytes are empty" ~count:1000 + bytes (fun b -> b = Bytes.empty) + + let bytes_never_has_000_char = + Test.make ~name:"bytes never has a \\000 char" ~count:1000 + bytes + (fun b -> Bytes.to_seq b |> Seq.fold_left (fun acc c -> acc && c <> '\000') true) + + let bytes_never_has_255_char = + Test.make ~name:"bytes never has a \\255 char" ~count:1000 + bytes + (fun s -> Bytes.to_seq s |> Seq.fold_left (fun acc c -> acc && c <> '\255') true) + + let bytes_unique_chars = + Test.make ~name:"bytes have unique chars" ~count:1000 + bytes + (fun s -> + let ch_list = Bytes.to_seq s |> List.of_seq in + List.length ch_list = List.length (List.sort_uniq Char.compare ch_list)) let strings_are_empty = Test.make ~name:"strings are empty" ~count:1000 @@ -676,6 +706,10 @@ module Shrink = struct char_is_never_abcdef; printable_is_never_sign; numeral_is_never_less_5; + bytes_are_empty; + bytes_never_has_000_char; + bytes_never_has_255_char; + bytes_unique_chars; strings_are_empty; string_never_has_000_char; string_never_has_255_char; @@ -842,12 +876,21 @@ module Stats = struct Test.make ~name:"numeral char code dist" ~count:500_000 (add_stat ("char code", Char.code) numeral_char) (fun _ -> true); ] + let bytes_len_tests = + let len = ("len",Bytes.length) in + [ + Test.make ~name:"bytes_size len dist" ~count:5_000 (add_stat len (bytes_of_size (Gen.int_range 5 10))) (fun _ -> true); + Test.make ~name:"bytes len dist" ~count:5_000 (add_stat len bytes) (fun _ -> true); + Test.make ~name:"bytes_of len dist" ~count:5_000 (add_stat len (bytes_of (Gen.return 'a'))) (fun _ -> true); + Test.make ~name:"bytes_small len dist" ~count:5_000 (add_stat len bytes_small) (fun _ -> true); + ] + let string_len_tests = let len = ("len",String.length) in [ Test.make ~name:"string_size len dist" ~count:5_000 (add_stat len (string_of_size (Gen.int_range 5 10))) (fun _ -> true); Test.make ~name:"string len dist" ~count:5_000 (add_stat len string) (fun _ -> true); - Test.make ~name:"string_of len dist" ~count:5_000 (add_stat len (string_gen (Gen.return 'a'))) (fun _ -> true); + Test.make ~name:"string_of len dist" ~count:5_000 (add_stat len (string_of (Gen.return 'a'))) (fun _ -> true); Test.make ~name:"printable_string len dist" ~count:5_000 (add_stat len printable_string) (fun _ -> true); Test.make ~name:"small_string len dist" ~count:5_000 (add_stat len small_string) (fun _ -> true); ] @@ -924,6 +967,7 @@ module Stats = struct @ char_dist_tests @ [tree_depth_test; range_subset_test;] + @ bytes_len_tests @ string_len_tests @ [pair_dist; triple_dist;