1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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")
}
}
|