adding csv test

This commit is contained in:
simon petit 2025-05-05 15:35:49 +00:00
parent f6c083ac43
commit e61ab45990
2 changed files with 30 additions and 1 deletions

View File

@ -6,8 +6,14 @@
(name test_logical_plan) (name test_logical_plan)
(libraries ast logical_plan alcotest)) (libraries ast logical_plan alcotest))
(test
(name test_csv)
(libraries csv ast logical_plan alcotest)
(deps
(file ./files/csv/data.csv)))
(test (test
(name test_parquet) (name test_parquet)
(libraries parquet) (libraries parquet)
(deps (deps
(file ./files/parquet/mock_data.parquet))) (file ./files/parquet/data.parquet)))

23
test/test_csv.ml Normal file
View File

@ -0,0 +1,23 @@
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
]
]