File tree Expand file tree Collapse file tree 4 files changed +14
-34
lines changed Expand file tree Collapse file tree 4 files changed +14
-34
lines changed Original file line number Diff line number Diff line change 1111 (deps t_appendix_a.exe appendix_a.json)
1212 (action
1313 (run ./t_appendix_a.exe ./appendix_a.json)))
14-
15- (executable
16- (name t)
17- (modules t)
18- (preprocess
19- (action
20- (run %{project_root}/src/core/cpp/cpp.exe %{input-file})))
21- (libraries qcheck-core qcheck-core.runner containers containers.cbor))
22-
23- (rule
24- (alias runtest)
25- (action
26- (run ./t.exe --no-colors)))
Original file line number Diff line number Diff line change 55 (preprocess
66 (action
77 (run %{project_root}/src/core/cpp/cpp.exe %{input-file})))
8- (libraries containers containers.bencode containers.unix threads
9- containers_testlib iter gen uutf csexp))
8+ (libraries containers containers.bencode containers.cbor containers.unix
9+ threads containers_testlib iter gen uutf csexp))
Original file line number Diff line number Diff line change @@ -33,5 +33,6 @@ Containers_testlib.run_all ~descr:"containers" [
3333 T_utf8string. get() ;
3434 T_vector. get() ;
3535 T_bencode. get() ;
36+ T_cbor. get() ;
3637 T_unix. get() ;
3738];;
Original file line number Diff line number Diff line change 11
2- module Q = QCheck
3- module Cbor = Containers_cbor
2+ include (val Containers_testlib. make ~__FILE__ () )
3+ module Cbor = Containers_cbor ;;
44
5- let suite = ref []
6-
7- [@@@ ifge 4.08 ]
5+ [@@@ ifge 4.08 ];;
86
97let gen_c : Cbor.t Q.Gen.t =
108 let open Q.Gen in
@@ -55,20 +53,14 @@ let rec shrink (c:Cbor.t) : Cbor.t Q.Iter.t =
5553 | `Bytes s ->
5654 let + s = Q.Shrink. string s in `Bytes s
5755
56+ let arb = Q. make ~shrink ~print: Cbor. to_string_diagnostic gen_c;;
5857
59- let arb = Q. make ~shrink ~print: Cbor. to_string_diagnostic gen_c
60-
61- let t1 =
62- Q.Test. make ~count: 10_000 ~name: " to_from_same" arb @@ fun c ->
63- let s = Cbor. encode c in
64- let c' = Cbor. decode_exn s in
65- if not (c = c') then
66- Q.Test. fail_reportf " @[<hv2>roundtrip failed:@ from %a@ to %a@]"
67- Cbor. pp_diagnostic c Cbor. pp_diagnostic c';
68- true
69-
70- let () = suite := t1 :: ! suite
58+ q ~count: 10_000 arb @@ fun c ->
59+ let s = Cbor. encode c in
60+ let c' = Cbor. decode_exn s in
61+ if not (c = c') then
62+ Q.Test. fail_reportf " @[<hv2>roundtrip failed:@ from %a@ to %a@]"
63+ Cbor. pp_diagnostic c Cbor. pp_diagnostic c';
64+ true ;;
7165
7266[@@@ endif]
73-
74- let () = QCheck_base_runner. run_tests_main ! suite
You can’t perform that action at this time.
0 commit comments