File: test_write.ml

package info (click to toggle)
ocaml-csv 1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 332 kB
  • ctags: 288
  • sloc: ml: 1,796; makefile: 99
file content (16 lines) | stat: -rw-r--r-- 425 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
open Printf

let roundtrip ?excel_tricks csv =
  let buf = Buffer.create 128 in
  Csv.output_all (Csv.to_buffer buf ?excel_tricks) csv;
  let csv' = Csv.input_all (Csv.of_string (Buffer.contents buf)) in
  if Csv.compare csv csv' <> 0 then (
    printf "Csv roundtrip:\n";
    Csv.print csv';
    printf "Expected:\n";
    Csv.print csv;
    failwith "failed!"
  )

let () =
  roundtrip [ [ "01234567" ] ] ~excel_tricks:true