mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add fuzzing for csexp
This commit is contained in:
parent
b2b1d2b5fa
commit
427c15e472
2 changed files with 21 additions and 5 deletions
19
fuzz/ccsexp_csexp_reparse.ml
Normal file
19
fuzz/ccsexp_csexp_reparse.ml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
let gen_sexp =
|
||||||
|
let open! Crowbar in
|
||||||
|
let (>|=) = map in
|
||||||
|
fix
|
||||||
|
(fun self ->
|
||||||
|
choose [
|
||||||
|
((bytes :: [] : _ gens) >|= fun s -> `Atom s);
|
||||||
|
((list self :: []) >|= fun l -> `List l);
|
||||||
|
])
|
||||||
|
|
||||||
|
let () =
|
||||||
|
Crowbar.add_test ~name:"ccsexp_csexp_reparse" [ gen_sexp ]
|
||||||
|
(fun s ->
|
||||||
|
let str = CCSexp.Canonical.to_string s in
|
||||||
|
match CCSexp.Canonical.parse_string_list str with
|
||||||
|
| Ok [s2] -> assert (s = s2)
|
||||||
|
| Ok _ -> failwith "wrong number of sexps"
|
||||||
|
| Error e -> failwith e)
|
||||||
|
|
@ -2,8 +2,5 @@
|
||||||
(flags (-w "+a-4-9-29-37-40-42-44-48-50-32" -g))
|
(flags (-w "+a-4-9-29-37-40-42-44-48-50-32" -g))
|
||||||
(names ccsexp_parse_string_does_not_crash
|
(names ccsexp_parse_string_does_not_crash
|
||||||
ccutf8_string_uchar_to_bytes_is_same_as_simple_version
|
ccutf8_string_uchar_to_bytes_is_same_as_simple_version
|
||||||
)
|
ccsexp_csexp_reparse)
|
||||||
(libraries crowbar
|
(libraries crowbar containers))
|
||||||
containers
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue