1package fileio23import (4 "context"5 "testing"67 "src.rest/cat/012/internal/sheet"8)910// A notebook's output takes the formats of the columns it read, where11// its values are still of their types.12func TestKeepFormats(t *testing.T) {13 w := sheet.NewBook()14 s := w.Sheet(0)15 for a, in := range map[string]string{"A1": "price", "B1": "bought", "C1": "n", "A2": "$3.50", "B2": "2026-09-29", "C2": "12%"} {16 at, _ := sheet.ParseAddr(a)17 s.Set(at, in)18 }19 formats := ColumnFormats(Snap(s, sheet.NewRect(sheet.Addr{}, sheet.Addr{Col: 2, Row: 1}), "Sheet1"))20 rows, _, err := NUONRows(context.Background(), []byte(`[[price, bought, n, other]; [4.25, 2026-10-01T00:00:00+00:00, "text", 7]]`), 0)21 if err != nil {22 t.Fatal(err)23 }24 KeepFormats(&rows, formats)25 row := rows.Rows[0]26 if row[0].F.Kind != sheet.FmtCurrency || row[1].F.Pattern != "yyyy-mm-dd" || row[2].V.Kind != sheet.Text || !row[3].F.IsZero() {27 t.Errorf("kept: %+v", row)28 }29}