aboutsummaryrefslogtreecommitdiff
path: root/mobile/mobile_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-04 00:11:23 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-04 00:11:23 +0200
commit197ce6980daa1c3773eed1548f54861d616d35e4 (patch)
tree58394c367c68ae8c5d3d7d7b1f5d42044b3b3ef0 /mobile/mobile_test.go
parent70c504148ca9ddf7fdb31162f5f8da7e118fca45 (diff)
downloadlectio-197ce6980daa1c3773eed1548f54861d616d35e4.tar.gz
lectio-197ce6980daa1c3773eed1548f54861d616d35e4.zip
mobile: strengthen the PartLabels fallback test and count bounds
Diffstat (limited to 'mobile/mobile_test.go')
-rw-r--r--mobile/mobile_test.go20
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)
}
}