aboutsummaryrefslogtreecommitdiff
path: root/internal/bible/books_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/bible/books_test.go')
-rw-r--r--internal/bible/books_test.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/bible/books_test.go b/internal/bible/books_test.go
index 43a67cf..e1a65ca 100644
--- a/internal/bible/books_test.go
+++ b/internal/bible/books_test.go
@@ -24,3 +24,43 @@ func TestResolveBook(t *testing.T) {
t.Error("ResolveBook(Nonsense) should fail")
}
}
+
+func TestBooksTableIntegrity(t *testing.T) {
+ if len(canonOrder) != len(aliasSeed) {
+ t.Fatalf("canonOrder has %d names, aliasSeed has %d", len(canonOrder), len(aliasSeed))
+ }
+ seen := map[string]bool{}
+ for _, name := range canonOrder {
+ if seen[name] {
+ t.Errorf("canonOrder duplicate %q", name)
+ }
+ seen[name] = true
+ a, ok := aliasSeed[name]
+ if !ok {
+ t.Errorf("canonOrder name %q missing from aliasSeed", name)
+ continue
+ }
+ if len(a) < 2 {
+ t.Errorf("book %q has %d aliases, need >=2 (abbrev, pl-name)", name, len(a))
+ }
+ }
+ for name := range aliasSeed {
+ if !seen[name] {
+ t.Errorf("aliasSeed name %q missing from canonOrder", name)
+ }
+ }
+}
+
+func TestBooksResolve(t *testing.T) {
+ for _, b := range Books() {
+ if b.English == "" || b.Polish == "" || b.Abbrev == "" {
+ t.Errorf("incomplete BookInfo %+v", b)
+ }
+ if c, ok := ResolveBook(b.Abbrev); !ok || c != b.English {
+ t.Errorf("abbrev %q resolved to (%q,%v), want %q", b.Abbrev, c, ok, b.English)
+ }
+ }
+ if got := len(Books()); got != 73 {
+ t.Errorf("Books() len = %d, want 73", got)
+ }
+}