1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package calendar
import "testing"
func efCand(rank Rank, temporal bool) candidate {
return candidate{Cel: Celebration{Rank: rank}, Temporal: temporal}
}
func TestPrecedenceEF(t *testing.T) {
c1 := efCand(RankClass1, false)
c3 := efCand(RankClass3, false)
c4 := efCand(RankClass4, false)
comm := efCand(RankCommemoration, false)
if !(precedenceEF(c1) < precedenceEF(c3) && precedenceEF(c3) < precedenceEF(c4) && precedenceEF(c4) < precedenceEF(comm)) {
t.Error("EF class ordering broken (class-1 > class-3 > class-4 > commemoration)")
}
// at equal class, the temporal office wins.
temp := efCand(RankClass2, true)
saint := efCand(RankClass2, false)
obs, _ := pickEF([]candidate{saint, temp})
if !obs.Temporal {
t.Error("equal-class: temporal office should be observed")
}
// a I-class feast beats a II-class Sunday.
obs2, others := pickEF([]candidate{efCand(RankClass2, true), efCand(RankClass1, false)})
if obs2.Cel.Rank != RankClass1 || len(others) != 1 {
t.Errorf("I-class feast should win over II-class Sunday, got %+v", obs2.Cel)
}
}
|