summaryrefslogtreecommitdiff
path: root/internal/bible/ofref_test.go
blob: 4455d94682f4a4730e3a3328c93e37231a0c76c7 (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
43
44
45
46
47
48
49
50
51
52
53
package bible

import "testing"

func TestOFRef(t *testing.T) {
	cases := []struct {
		name     string
		citation string
		system   string
		want     string
	}{
		// Non-psalms pass through unchanged in every system.
		{"gospel-vulgate", "Matthew 4:12-23", "vulgate", "Matthew 4:12-23"},
		{"gospel-drb", "Matthew 4:12-23", "drb", "Matthew 4:12-23"},
		{"epistle-hebrew", "1 Corinthians 1:10-13,17", "hebrew", "1 Corinthians 1:10-13,17"},

		// Psalm chapter shift for the Vulgate family (Hebrew -> Vulgate).
		{"ps27-vulgate", "Psalms 27:1,4,13-14", "vulgate", "Psalms 26:1,4,13-14"},
		{"ps27-drb", "Psalms 27:1,4,13-14", "drb", "Psalms 27:1,4,13-14"}, // Ps 27 has no DRB title fold
		{"ps27-hebrew", "Psalms 27:1,4,13-14", "hebrew", "Psalms 27:1,4,13-14"},

		// Verse-accurate Hebrew->Vulgate mapping, including the joined/split psalms.
		{"ps8-vulgate", "Psalms 8:2", "vulgate", "Psalms 8:2"},       // <=8 unchanged
		{"ps9-vulgate", "Psalms 9:2", "vulgate", "Psalms 9:2"},       // Heb 9 = Vulg 9
		{"ps10-vulgate", "Psalms 10:1", "vulgate", "Psalms 9:22"},    // Heb 10:1 = Vulg 9:22
		{"ps11-vulgate", "Psalms 11:1", "vulgate", "Psalms 10:1"},    // 11..113 -> h-1
		{"ps115-vulgate", "Psalms 115:1", "vulgate", "Psalms 113:9"}, // Heb 115:1 = Vulg 113:9
		{"ps116a-vulgate", "Psalms 116:1-9", "vulgate", "Psalms 114:1-9"},
		{"ps116b-vulgate", "Psalms 116:12-13,17-18", "vulgate", "Psalms 115:3-4,8-9"},
		{"ps147a-vulgate", "Psalms 147:1-11", "vulgate", "Psalms 146:1-11"},
		{"ps147b-vulgate", "Psalms 147:12-13,19-20", "vulgate", "Psalms 147:1-2,8-9"},
		{"ps148-vulgate", "Psalms 148:1", "vulgate", "Psalms 148:1"}, // >=148 unchanged

		// DRB title-fold verse shift: Ps 51 folds 2 title verses into verse 1.
		{"ps51-drb", "Psalms 51:3-4,12-13", "drb", "Psalms 51:1-2,10-11"},
		{"ps51-vulgate", "Psalms 51:3-4", "vulgate", "Psalms 50:3-4"},
		// Ps 63 folds 1 title verse.
		{"ps63-drb", "Psalms 63:2,3-4", "drb", "Psalms 63:1,2-3"},

		// Tail normalization: sub-verse letters dropped, ";" -> ",".
		{"verseletter-2sam", "2 Samuel 6:12b-15,17-19", "vulgate", "2 Samuel 6:12-15,17-19"},
		{"semicolon-acts", "The Acts 11:21b-26;13:1-3", "drb", "The Acts 11:21-26,13:1-3"},
		{"multiletter-psalm-drb", "Psalms 98:1,2-3ab,3cd-4,5-6", "drb", "Psalms 98:1,2-3,3-4,5-6"},
		{"multiletter-psalm-vulgate", "Psalms 98:1,2-3ab,3cd-4,5-6", "vulgate", "Psalms 97:1,2-3,3-4,5-6"},
	}
	for _, c := range cases {
		t.Run(c.name, func(t *testing.T) {
			if got := OFRef(c.citation, c.system); got != c.want {
				t.Errorf("OFRef(%q, %q) = %q, want %q", c.citation, c.system, got, c.want)
			}
		})
	}
}