aboutsummaryrefslogtreecommitdiff
path: root/internal/bible/booktable_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 13:35:24 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 13:35:24 +0200
commit22bfec8fc13a20a8d95a4609b4a02bb48acede5a (patch)
tree6416eb2345df1885863063e931e72222fdd622bc /internal/bible/booktable_test.go
parent4c23ae5107690a77a4253eaecbb7dfa822bdffc3 (diff)
downloadlectio-22bfec8fc13a20a8d95a4609b4a02bb48acede5a.tar.gz
lectio-22bfec8fc13a20a8d95a4609b4a02bb48acede5a.zip
citation: render --citation/--week gospel ref in the configured sigla dialect (bible.FormatRef); v0.11.0
Diffstat (limited to 'internal/bible/booktable_test.go')
-rw-r--r--internal/bible/booktable_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/bible/booktable_test.go b/internal/bible/booktable_test.go
index ededad3..2a57d80 100644
--- a/internal/bible/booktable_test.go
+++ b/internal/bible/booktable_test.go
@@ -64,6 +64,37 @@ func TestParseRefDialects(t *testing.T) {
}
}
+func TestFormatRef(t *testing.T) {
+ tbl, _ := LoadBookTable(nil)
+ cases := []struct {
+ dialect, canonical, want string
+ }{
+ {"en", "John 20:1,11-18", "Jn 20:1,11-18"},
+ {"pl", "John 20:1,11-18", "J 20, 1. 11-18"},
+ {"en", "Matthew 13:18-23", "Matt 13:18-23"},
+ {"pl", "Matthew 13:18-23", "Mt 13, 18-23"},
+ {"en", "Luke 16:1-9", "Lk 16:1-9"},
+ // Round-trip: ParseRef then FormatRef in the same dialect is stable.
+ }
+ for _, c := range cases {
+ if got := tbl.FormatRef(c.dialect, c.canonical); got != c.want {
+ t.Errorf("FormatRef(%q,%q)=%q want %q", c.dialect, c.canonical, got, c.want)
+ }
+ }
+ // Unparseable / unknown book -> unchanged (safe fallback).
+ if got := tbl.FormatRef("en", "not a ref"); got != "not a ref" {
+ t.Errorf("unparseable ref should be unchanged, got %q", got)
+ }
+ // Round-trip through both dialects.
+ canon, ok := tbl.ParseRef("pl", "J 20, 1. 11-18")
+ if !ok || canon != "John 20:1,11-18" {
+ t.Fatalf("ParseRef round-trip canon=%q ok=%v", canon, ok)
+ }
+ if got := tbl.FormatRef("pl", canon); got != "J 20, 1. 11-18" {
+ t.Errorf("pl round-trip = %q", got)
+ }
+}
+
func TestBookTableMergeAndMalformed(t *testing.T) {
// User adds an alias "Jhn" to English John; other books stay default.
user := []byte("[en]\nJohn = [\"Jn\", \"Jhn\", \"John\"]\n")