diff options
Diffstat (limited to 'internal/calendar/datespec_test.go')
| -rw-r--r-- | internal/calendar/datespec_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/calendar/datespec_test.go b/internal/calendar/datespec_test.go new file mode 100644 index 0000000..e5e34c0 --- /dev/null +++ b/internal/calendar/datespec_test.go @@ -0,0 +1,24 @@ +package calendar + +import ( + "testing" +) + +func TestResolveDate(t *testing.T) { + y := 2025 + e := Easter(y) // 2025-04-20 + check := func(spec, want string) { + got, ok := resolveDate(DateSpec(spec), y, e) + if !ok || got.Format("2006-01-02") != want { + t.Errorf("resolveDate(%q) = %s ok=%v, want %s", spec, got.Format("2006-01-02"), ok, want) + } + } + check("08-15", "2025-08-15") // fixed + check("easter+60", "2025-06-19") // Corpus Christi (Thursday) + check("easter-46", "2025-03-05") // Ash Wednesday + check("christmas+7", "2026-01-01") + check("sunday-after 01-06", "2025-01-12") + if _, ok := resolveDate("garbage", y, e); ok { + t.Error("garbage should not resolve") + } +} |
