summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/utility/csv.pngbin0 -> 8603 bytes
-rw-r--r--tests/res/bad.csv4
-rw-r--r--tests/res/zoo.csv4
-rw-r--r--tests/typ/utility/csv.typ15
4 files changed, 23 insertions, 0 deletions
diff --git a/tests/ref/utility/csv.png b/tests/ref/utility/csv.png
new file mode 100644
index 00000000..69e0ae38
--- /dev/null
+++ b/tests/ref/utility/csv.png
Binary files differ
diff --git a/tests/res/bad.csv b/tests/res/bad.csv
new file mode 100644
index 00000000..2c2696e9
--- /dev/null
+++ b/tests/res/bad.csv
@@ -0,0 +1,4 @@
+A,B
+1,2
+3,4,5
+6,7
diff --git a/tests/res/zoo.csv b/tests/res/zoo.csv
new file mode 100644
index 00000000..42ff06c7
--- /dev/null
+++ b/tests/res/zoo.csv
@@ -0,0 +1,4 @@
+Name,Species,Weight,Length
+Debby,Rhinoceros,1900kg,390cm
+Fluffy,Tiger,115kg,310cm
+Sleepy,Dolphin,150kg,180cm
diff --git a/tests/typ/utility/csv.typ b/tests/typ/utility/csv.typ
new file mode 100644
index 00000000..ab955ab0
--- /dev/null
+++ b/tests/typ/utility/csv.typ
@@ -0,0 +1,15 @@
+// Test reading structured CSV data.
+
+---
+#set page(width: auto)
+#let data = csv("/res/zoo.csv")
+#let cells = data(0).map(strong) + data.slice(1).flatten()
+#table(columns: data(0).len(), ..cells)
+
+---
+// Error: 6-16 file not found (searched at typ/utility/nope.csv)
+#csv("nope.csv")
+
+---
+// Error: 6-20 failed to load csv file (CSV error: record 2 (line: 3, byte: 8): found record with 3 fields, but the previous record has 2 fields)
+#csv("/res/bad.csv")