Skip to content

Commit 43f88a3

Browse files
committed
stronger test for cbor
1 parent 20fb411 commit 43f88a3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/cbor/tests/t.ml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@ let gen_c : Cbor.t Q.Gen.t =
1515
(1, return `Undefined);
1616
(3, let+ x = int in `Int x);
1717
(1, let+ b = bool in `Bool b);
18+
(1, let+ x = 0 -- 19 in `Simple x);
19+
(1, let+ x = 26 -- 127 in `Simple x);
1820
(1, let+ f = float in `Float f);
1921
(2, let+ s = string_size ~gen:printable (0--150) in `Text s);
2022
(2, let+ s = string_size ~gen:char (0--150) in `Bytes s);
2123
] in
24+
let g_base = frequency base in
2225
let rec_ = [
23-
(2, let+ l = list_size (0--5) recurse in `Array l);
24-
(2, let+ l = list_size (0--5) (pair (frequency base) recurse) in `Map l);
26+
(2, let+ l =
27+
if size>10 then list_size (0--1024) g_base
28+
else list_size (0--10) recurse
29+
in `Array l);
30+
(2, let+ l =
31+
if size>10 then list_size (0--1024) (pair g_base g_base)
32+
else list_size (0--5) (pair g_base recurse)
33+
in `Map l);
2534
]in
2635
frequency (if size>0 then base @ rec_ else base)
2736

@@ -50,7 +59,7 @@ let rec shrink (c:Cbor.t) : Cbor.t Q.Iter.t =
5059
let arb = Q.make ~shrink ~print:Cbor.to_string_diagnostic gen_c
5160

5261
let t1 =
53-
Q.Test.make ~count:100_000 ~name:"to_from_same" arb @@ fun c ->
62+
Q.Test.make ~count:10_000 ~name:"to_from_same" arb @@ fun c ->
5463
let s = Cbor.encode c in
5564
let c' = Cbor.decode_exn s in
5665
if not (c = c') then

0 commit comments

Comments
 (0)