From 020294fca9a7065d4b9cf4e677f606ebaaa29b00 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 13 Apr 2024 10:39:45 +0200 Subject: Better test runner (#3922) --- tests/suite/loading/csv.typ | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/suite/loading/csv.typ (limited to 'tests/suite/loading/csv.typ') diff --git a/tests/suite/loading/csv.typ b/tests/suite/loading/csv.typ new file mode 100644 index 00000000..415488fc --- /dev/null +++ b/tests/suite/loading/csv.typ @@ -0,0 +1,27 @@ +--- csv --- +// Test reading CSV data. +#set page(width: auto) +#let data = csv("/assets/data/zoo.csv") +#let cells = data.at(0).map(strong) + data.slice(1).flatten() +#table(columns: data.at(0).len(), ..cells) + +--- csv-row-type-dict --- +// Test reading CSV data with dictionary rows enabled. +#let data = csv("/assets/data/zoo.csv", row-type: dictionary) +#test(data.len(), 3) +#test(data.at(0).Name, "Debby") +#test(data.at(2).Weight, "150kg") +#test(data.at(1).Species, "Tiger") + +--- csv-file-not-found --- +// Error: 6-16 file not found (searched at tests/suite/loading/nope.csv) +#csv("nope.csv") + +--- csv-invalid --- +// Error: 6-28 failed to parse CSV (found 3 instead of 2 fields in line 3) +#csv("/assets/data/bad.csv") + +--- csv-invalid-row-type-dict --- +// Test error numbering with dictionary rows. +// Error: 6-28 failed to parse CSV (found 3 instead of 2 fields in line 3) +#csv("/assets/data/bad.csv", row-type: dictionary) -- cgit v1.2.3