diff options
Diffstat (limited to 'internal/bible/bible_test.go')
| -rw-r--r-- | internal/bible/bible_test.go | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/internal/bible/bible_test.go b/internal/bible/bible_test.go index 71a2c89..e3c18c8 100644 --- a/internal/bible/bible_test.go +++ b/internal/bible/bible_test.go @@ -14,24 +14,40 @@ func TestVerses(t *testing.T) { {"wuj", "Wisdom", 3, 1, "A dusze sprawiedliwych"}, // deuterocanonical } for _, c := range cases { - vs := Verses(c.version, c.book, c.chap) - var got string - for _, v := range vs { - if v.Verse == c.verse { - got = v.Text + t.Run(c.version+"/"+c.book, func(t *testing.T) { + requireCorpus(t, c.version) + vs := Verses(c.version, c.book, c.chap) + var got string + for _, v := range vs { + if v.Verse == c.verse { + got = v.Text + } } - } - if !hasPrefix(got, c.wantPrefix) { - t.Errorf("%s %s %d:%d = %q want prefix %q", c.version, c.book, c.chap, c.verse, got, c.wantPrefix) - } + if !hasPrefix(got, c.wantPrefix) { + t.Errorf("%s %s %d:%d = %q want prefix %q", c.version, c.book, c.chap, c.verse, got, c.wantPrefix) + } + }) } } func hasPrefix(s, p string) bool { return len(s) >= len(p) && s[:len(p)] == p } +// requireCorpus skips the test when corpus `code` is not available. The optional +// corpora (wuj, drb, grb) are compiled in only with `-tags fullbible` (or dropped +// into the user corpora dir); without that, only vul is embedded. Keying on +// Meta() means these tests run fully under fullbible and skip -- not fail -- +// under the default build, so `go test ./...` stays honest either way. +func requireCorpus(t *testing.T, code string) { + t.Helper() + if _, ok := Meta(code); !ok { + t.Skipf("corpus %q not embedded; build with -tags fullbible", code) + } +} + // TestGrbNoApparatusMarkers guards the corpus fix: the SBLGNT apparatus sigla // (U+2E00–U+2E0D) were stripped from the Greek text. func TestGrbNoApparatusMarkers(t *testing.T) { + requireCorpus(t, "grb") for _, v := range Verses("grb", "Luke", 16) { for _, r := range v.Text { if r >= 0x2E00 && r <= 0x2E0D { @@ -53,6 +69,7 @@ func TestVul2Kings(t *testing.T) { } func TestCorpusBooks(t *testing.T) { + requireCorpus(t, "wuj") books := CorpusBooks("wuj") if len(books) == 0 { t.Fatal("wuj corpus has no books") @@ -72,6 +89,7 @@ func TestCorpusBooks(t *testing.T) { } func TestChapters(t *testing.T) { + requireCorpus(t, "wuj") ch := Chapters("wuj", "John") if len(ch) == 0 || ch[0] != 1 { t.Fatalf("John chapters = %v", ch) |
