Skip to content

Commit

Permalink
add fuzzing for csexp
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Feb 3, 2021
1 parent b2b1d2b commit 427c15e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
19 changes: 19 additions & 0 deletions fuzz/ccsexp_csexp_reparse.ml
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 2 additions & 5 deletions fuzz/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,5 @@
(flags (-w "+a-4-9-29-37-40-42-44-48-50-32" -g))
(names ccsexp_parse_string_does_not_crash
ccutf8_string_uchar_to_bytes_is_same_as_simple_version
)
(libraries crowbar
containers
)
)
ccsexp_csexp_reparse)
(libraries crowbar containers))

0 comments on commit 427c15e

Please sign in to comment.