aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mobile/mobile.go4
-rw-r--r--mobile/mobile_test.go20
2 files changed, 20 insertions, 4 deletions
diff --git a/mobile/mobile.go b/mobile/mobile.go
index d863463..d91831c 100644
--- a/mobile/mobile.go
+++ b/mobile/mobile.go
@@ -8,7 +8,9 @@
// document with the day's identity and rendered Mass readings. All liturgical
// computation and text resolution happens here, in the exact validated lectio
// engine — the app does none of it. Keep every exported signature to types
-// gomobile can marshal (string in, string out): that is why the payload is JSON.
+// gomobile can marshal -- strings and ints only -- with JSON as the payload
+// format for everything structured. A Go int parameter (e.g. Days' count)
+// surfaces on the Kotlin side as a long, not an Int.
package mobile
import (
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)
}
}