add fuzzing for csexp

This commit is contained in:
Simon Cruanes 2021-02-02 22:48:08 -05:00
parent b2b1d2b5fa
commit 427c15e472
2 changed files with 21 additions and 5 deletions

View 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)

View file

@ -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
)
)