test: add tests for csv reader and writer

This commit is contained in:
2025-08-31 15:20:52 +03:00
parent 454c632462
commit fe9568d7ae
4 changed files with 73 additions and 0 deletions

29
input_csv_test.go Normal file
View File

@@ -0,0 +1,29 @@
package script_test
import (
"slices"
"testing"
"code.uint32.ru/dmitry/script"
)
func TestCSVReader(t *testing.T) {
t.Parallel()
r, err := script.NewCSVReader("testdata/sample_csv.csv")
if err != nil {
t.Fatal(err)
}
want := []string{"one", "two", "three"}
for range 2 {
row, err := r.Read()
if err != nil {
t.Fatal(err)
}
if !slices.Equal(row, want) {
t.Fatalf("rows not equal, want: %v, have: %v", want, row)
}
}
}