diff options
Diffstat (limited to 'mobile/mobile_test.go')
| -rw-r--r-- | mobile/mobile_test.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/mobile/mobile_test.go b/mobile/mobile_test.go index 1a115f3..cf75b7f 100644 --- a/mobile/mobile_test.go +++ b/mobile/mobile_test.go @@ -111,6 +111,7 @@ func TestDaysRejectsBadInput(t *testing.T) { count int }{ {"not-a-date", 7}, {"2026-08-01", 0}, {"2026-08-01", -1}, {"2026-08-01", 400}, + {"2026-08-01", 367}, // one past the documented upper bound } { if got := Days(c.start, c.count, "of", "pl"); got != "[]" { t.Errorf("Days(%q, %d) = %s, want []", c.start, c.count, got) @@ -118,6 +119,16 @@ func TestDaysRejectsBadInput(t *testing.T) { } } +// count's documented range is 1..366; 367 (above) is the first invalid value +// and 366 (here) is the last valid one -- the boundary an off-by-one would +// actually live on. +func TestDaysAcceptsUpperBoundCount(t *testing.T) { + a := decodeDays(t, Days("2026-01-01", 366, "of", "en")) + if len(a) != 366 { + t.Errorf("got %d elements, want 366", len(a)) + } +} + func BenchmarkDaysWeek(b *testing.B) { for i := 0; i < b.N; i++ { Days("2026-07-27", 7, "of", "pl") @@ -163,8 +174,11 @@ func TestPartLabelsMatchesWhatTheEngineEmits(t *testing.T) { } func TestPartLabelsUnknownForm(t *testing.T) { - // An unknown form is treated as the modern one, matching lectByForm. - if got := PartLabels("nonsense", "en"); got == "[]" { - t.Error("unknown form should fall back to the modern lectionary, not empty") + // An unknown form is treated as the modern one, matching lectByForm: the + // fallback must be byte-identical to "of", not merely non-empty. + got := PartLabels("nonsense", "en") + want := PartLabels("of", "en") + if got != want { + t.Errorf("PartLabels(\"nonsense\", \"en\") = %s, want %s (same as \"of\")", got, want) } } |
