X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=test.ml;fp=test.ml;h=a8537a5ee671bfd2a3803bf244e1a0135533aad7;hb=bde8fd1d0283f16620624155a9bfb0b4e67feca9;hp=2ab02ad87835111e1fed9defe247e36a9e7c97e7;hpb=ae6f56ba8e80a1c05aa076404dd14145b306780a;p=ocaml-csv.git diff --git a/test.ml b/test.ml index 2ab02ad..a8537a5 100644 --- a/test.ml +++ b/test.ml @@ -1,4 +1,4 @@ -(* $Id: test.ml,v 1.1 2003-12-17 16:05:08 rich Exp $ *) +(* $Id: test.ml,v 1.2 2006-02-23 15:24:25 rich Exp $ *) open Printf open Csv @@ -13,16 +13,17 @@ let do_testcsv filename expected = print expected; failwith "failed" ) + else () -let testcsv1 = +let () = do_testcsv "testcsv1.csv" [ [ "This is a test\nwith commas,,,,,\n\nand carriage returns." ] ] -let testcsv2 = +let () = do_testcsv "testcsv2.csv" [ [ "Normal field"; "Quoted field"; "Quoted field with \"\" quotes" ] ] -let testcsv3 = +let () = do_testcsv "testcsv3.csv" [ [ "" ]; @@ -30,23 +31,42 @@ let testcsv3 = [ ""; ""; "" ]; [ ""; ""; ""; "" ]; [ ""; ""; ""; ""; "" ] ] -let testcsv4 = +let () = do_testcsv "testcsv4.csv" [] -let testcsv5 = +let () = do_testcsv "testcsv5.csv" [ [ "This is a test\nwith commas,,,,,\n\nand carriage returns."; "a second field"; "a third field" ]; [ "a fourth field on a new line" ] ] -let testcsv6 = +let () = do_testcsv "testcsv6.csv" [ [ "This is a test\nwith commas,,,,,\n\nand carriage returns\nand \000"; "a second field"; "a third field" ]; [ "a fourth field on a new line" ] ] +let () = + let csv1 = [ [ "a"; "b"; "c"; ""; "" ]; + [ "f"; "g"; "h"; "i"; "" ]; + [ "" ]; + [ ] ] in + let csv2 = trim ~top:false ~left:false ~right:true ~bottom:true csv1 in + assert (compare csv1 csv2 = 0) +let () = + let csv1 = [ [ "a"; "b"; "c"; ""; "" ]; + [ "f"; "g"; "h"; "i"; "" ]; + [ "" ]; + [ ] ] in + let csv2 = [ [ "a"; "b"; "c"; "d"; "" ]; + [ "f"; "g"; "h"; "i"; "" ]; + [ "" ]; + [ ] ] in + assert (compare csv1 csv2 < 0) + + ;; print_endline "All tests succeeded."