1 (* $Id: test.ml,v 1.2 2006-02-23 15:24:25 rich Exp $ *)
6 let do_testcsv filename expected =
7 let csv = load filename in
8 if csv <> expected then (
9 printf "input file: %s\n" filename;
10 printf "Csv library produced:\n";
21 [ [ "This is a test\nwith commas,,,,,\n\nand carriage returns." ] ]
25 [ [ "Normal field"; "Quoted field"; "Quoted field with \"\" quotes" ] ]
33 [ ""; ""; ""; ""; "" ] ]
41 [ [ "This is a test\nwith commas,,,,,\n\nand carriage returns.";
42 "a second field"; "a third field" ];
43 [ "a fourth field on a new line" ] ]
47 [ [ "This is a test\nwith commas,,,,,\n\nand carriage returns\nand \000";
48 "a second field"; "a third field" ];
49 [ "a fourth field on a new line" ] ]
52 let csv1 = [ [ "a"; "b"; "c"; ""; "" ];
53 [ "f"; "g"; "h"; "i"; "" ];
56 let csv2 = trim ~top:false ~left:false ~right:true ~bottom:true csv1 in
57 assert (compare csv1 csv2 = 0)
59 let csv1 = [ [ "a"; "b"; "c"; ""; "" ];
60 [ "f"; "g"; "h"; "i"; "" ];
63 let csv2 = [ [ "a"; "b"; "c"; "d"; "" ];
64 [ "f"; "g"; "h"; "i"; "" ];
67 assert (compare csv1 csv2 < 0)
72 print_endline "All tests succeeded."