File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ let bool ?(shrinker = Shrinker.Default) () =
138138let char ?root ?(shrinker = Shrinker. Default ) ?(printable = true ) () =
139139 let base = if printable then Char. code 'a' else 0 in
140140 let max = if printable then 26 else 256 in
141- let root = root |> Option. map (fun root -> Char. code root - Char. code 'a' ) in
141+ let root = root |> Option. map (fun root -> Char. code root - base ) in
142142 match shrinker with
143143 | Manual shrinker ->
144144 let *! root = int ?root ~min: 0 ~max () in
Original file line number Diff line number Diff line change @@ -33,6 +33,18 @@ let std_oneof () =
3333 let str = values |> List. map string_of_int |> String. concat " " in
3434 Regression. capture str ; Lwt. return_unit
3535
36+ let std_char_custom_root () =
37+ Test. register ~__FILE__ ~title: " std char custom root"
38+ ~tags: [" std" ; " char" ; " root" ]
39+ @@ fun () ->
40+ let gen = Bam.Std. char ~printable: false ~root: (Char. chr 5 ) () in
41+ let v =
42+ Bam.Gen. run gen (Bam.Gen.Random. make [|0 |]) |> Bam.Tree. root |> Char. code
43+ in
44+ if v = 5 then Lwt. return_unit
45+ else Test. failf " expected 5 got %d" v
46+
3647let register () =
3748 std_int_range_inclusive_bounds () ;
38- std_oneof ()
49+ std_oneof () ;
50+ std_char_custom_root ()
You can’t perform that action at this time.
0 commit comments