24 lines
502 B
OCaml
24 lines
502 B
OCaml
open Csv
|
|
open Alcotest
|
|
|
|
(* Function to read CSV file *)
|
|
let read_csv filename =
|
|
let ic = open_in filename in
|
|
let csv = Csv.load_in ic in
|
|
csv
|
|
|
|
(* Test to check if the CSV file is read correctly *)
|
|
let test_read_csv () =
|
|
let csv_data = read_csv "files/csv/data.csv" in
|
|
let nb_columns = Csv.columns csv_data in
|
|
check int "Number of columns" nb_columns 5
|
|
|
|
|
|
(* Run the test *)
|
|
let () =
|
|
run "CSV Tests" [
|
|
"Read CSV", [
|
|
test_case "Read and validate CSV" `Quick test_read_csv
|
|
]
|
|
]
|