package jalali import ( "testing" "time" ) func TestKnownDates(t *testing.T) { tests := []struct { gregorian string jalali Date }{ {"2024-03-20", Date{1403, 1, 1}}, {"2025-03-21", Date{1404, 1, 1}}, {"2026-07-28", Date{1405, 5, 6}}, } for _, tt := range tests { g, _ := time.Parse("2006-01-02", tt.gregorian) if got := FromTime(g); got != tt.jalali { t.Errorf("%s: got %v, want %v", tt.gregorian, got, tt.jalali) } back := ToGregorian(tt.jalali.Year, tt.jalali.Month, tt.jalali.Day) if got := back.Format("2006-01-02"); got != tt.gregorian { t.Errorf("%v: got %s, want %s", tt.jalali, got, tt.gregorian) } } } func TestMonthLength(t *testing.T) { if got := DaysInMonth(1399, 12); got != 30 { t.Fatalf("leap Esfand: got %d, want 30", got) } if got := DaysInMonth(1400, 12); got != 29 { t.Fatalf("regular Esfand: got %d, want 29", got) } }