From eea9d8139e5f10eab037dfeb9e4688d0c0f5c38d Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sat, 26 Mar 2016 12:31:00 +0100 Subject: [PATCH] additional test for CCParse (using temp file) --- src/string/CCParse.ml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/string/CCParse.ml b/src/string/CCParse.ml index ab1235a5..db34c1ec 100644 --- a/src/string/CCParse.ml +++ b/src/string/CCParse.ml @@ -121,6 +121,31 @@ exception ParseError of line_num * col_num * (unit -> string) *) +(* test with a temporary file *) +(*$R + let test n = + let p = CCParse.(U.list ~sep:"," U.int) in + + let l = CCList.(1 -- n) in + let l' = + CCIO.File.with_temp ~temp_dir:"/tmp/" + ~prefix:"containers_test" ~suffix:"" + (fun name -> + (* write test into file *) + CCIO.with_out name + (fun oc -> + let fmt = Format.formatter_of_out_channel oc in + Format.fprintf fmt "@[%a@]@." + (CCList.print ~sep:"," ~start:"[" ~stop:"]" CCInt.print) l); + (* parse it back *) + CCParse.parse_file_exn ~size:1024 ~file:name ~p) + in + assert_equal ~printer:Q.Print.(list int) l l' + in + test 100_000; + test 400_000; +*) + let const_ x () = x let input_of_string s =