package excelext import ( "testing" "time" "git.blackforestbytes.com/BlackForestBytes/goext/rfctime" "git.blackforestbytes.com/BlackForestBytes/goext/tst" ) func TestCellAddress(t *testing.T) { tst.AssertEqual(t, c(1, 0), "A1") tst.AssertEqual(t, c(1, 1), "B1") tst.AssertEqual(t, c(2, 0), "A2") tst.AssertEqual(t, c(10, 25), "Z10") tst.AssertEqual(t, c(1, 26), "AA1") tst.AssertEqual(t, c(99, 27), "AB99") tst.AssertEqual(t, c(100, 51), "AZ100") tst.AssertEqual(t, c(1, 52), "BA1") } func TestExcelizeOptTimeNil(t *testing.T) { got := excelizeOptTime(nil) if got != "" { t.Errorf("expected empty string for nil time, got %v", got) } } func TestExcelizeOptTimeValue(t *testing.T) { now := time.Date(2024, 5, 17, 13, 45, 30, 0, time.UTC) rt := rfctime.RFC3339NanoTime(now) got := excelizeOptTime(&rt) gt, ok := got.(time.Time) if !ok { t.Fatalf("expected time.Time, got %T", got) } if !gt.Equal(now) { t.Errorf("expected %v, got %v", now, gt) } } func TestExcelizeOptDateNil(t *testing.T) { got := excelizeOptDate(nil) if got != "" { t.Errorf("expected empty string for nil date, got %v", got) } } func TestExcelizeOptDateValue(t *testing.T) { d := rfctime.NewDate(time.Date(2025, 11, 3, 0, 0, 0, 0, time.UTC)) got := excelizeOptDate(&d) gt, ok := got.(time.Time) if !ok { t.Fatalf("expected time.Time, got %T", got) } if gt.Year() != 2025 || gt.Month() != 11 || gt.Day() != 3 { t.Errorf("unexpected date returned: %v", gt) } }