aboutsummaryrefslogtreecommitdiff
path: root/internal/calendar/precedence_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/calendar/precedence_test.go')
-rw-r--r--internal/calendar/precedence_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/calendar/precedence_test.go b/internal/calendar/precedence_test.go
new file mode 100644
index 0000000..6d9dc15
--- /dev/null
+++ b/internal/calendar/precedence_test.go
@@ -0,0 +1,36 @@
+package calendar
+
+import "testing"
+
+func tempCand(rank Rank, class Class, priv bool, s Season) candidate {
+ return candidate{Cel: Celebration{Rank: rank, Class: class}, Temporal: true, Privileged: priv, Season: s}
+}
+func saintCand(rank Rank, class Class) candidate {
+ return candidate{Cel: Celebration{Rank: rank, Class: class}, Temporal: false, Season: Ordinary}
+}
+
+func TestPrecedenceBands(t *testing.T) {
+ sundayLent := tempCand(RankSolemnity, ClassNone, true, Lent)
+ genSolemnity := saintCand(RankSolemnity, ClassSaint)
+ genFeast := saintCand(RankFeast, ClassSaint)
+ genMemorial := saintCand(RankMemorial, ClassSaint)
+ // A Sunday of Lent is band 2; a general solemnity is band 3 → the Sunday wins.
+ if !(precedence(sundayLent) < precedence(genSolemnity)) {
+ t.Error("Sunday of Lent (band 2) must outrank a general solemnity (band 3)")
+ }
+ if !(precedence(genSolemnity) < precedence(genFeast) && precedence(genFeast) < precedence(genMemorial)) {
+ t.Error("solemnity > feast > memorial ordering broken")
+ }
+}
+
+func TestPick(t *testing.T) {
+ sunday := tempCand(RankSolemnity, ClassNone, true, Ordinary)
+ memorial := saintCand(RankMemorial, ClassSaint)
+ obs, others := pick([]candidate{memorial, sunday})
+ if obs.Cel.Rank != RankSolemnity || !obs.Temporal {
+ t.Errorf("Sunday must win, got %+v", obs.Cel)
+ }
+ if len(others) != 1 || others[0].Cel.Rank != RankMemorial {
+ t.Errorf("memorial should be a commemoration, got %+v", others)
+ }
+}