summaryrefslogtreecommitdiff
path: root/internal/bible/ref_test.go
blob: 0c81a407fee7cd5dfaacfc9993e006ed5d340459 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package bible

import "testing"

func TestSplitRef(t *testing.T) {
	got := SplitRef("John 20:1,11-18")
	want := []string{"John 20:1", "John 20:11-18"}
	if len(got) != 2 || got[0] != want[0] || got[1] != want[1] {
		t.Fatalf("SplitRef mixed = %v want %v", got, want)
	}
	if g := SplitRef("Mat 7:1-5"); len(g) != 1 || g[0] != "Mat 7:1-5" {
		t.Errorf("SplitRef contiguous = %v", g)
	}
}

func TestLookup(t *testing.T) {
	t.Run("wuj", func(t *testing.T) {
		requireCorpus(t, "wuj")
		vs, missing := Lookup("wuj", "John 20:1,11-18")
		if len(missing) != 0 {
			t.Fatalf("missing = %v", missing)
		}
		if len(vs) == 0 || vs[0].Verse != 1 {
			t.Fatalf("first verse = %+v", vs)
		}
		last := vs[len(vs)-1]
		if last.Verse != 18 {
			t.Errorf("last verse = %d want 18", last.Verse)
		}
	})
	// Deuterocanon in the always-embedded Clementine Vulgate.
	if vs, m := Lookup("vul", "Wisdom 3:1"); len(m) != 0 || len(vs) == 0 {
		t.Errorf("vul Wisdom 3:1: missing=%v verses=%d (deuterocanon should resolve)", m, len(vs))
	}
	// Deuterocanon in Douay-Rheims (optional corpus).
	t.Run("drb", func(t *testing.T) {
		requireCorpus(t, "drb")
		if vs, m := Lookup("drb", "Judith 13:22"); len(m) != 0 || len(vs) == 0 {
			t.Errorf("drb Judith 13:22: missing=%v verses=%d (deuterocanon should resolve)", m, len(vs))
		}
	})
}