-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparse_test.go
More file actions
143 lines (118 loc) · 4.29 KB
/
parse_test.go
File metadata and controls
143 lines (118 loc) · 4.29 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package romanus
import (
"testing"
"github.com/stretchr/testify/assert"
)
var c = NewCatechism()
func TestCatechism_GetPart(t *testing.T) {
part, err := c.GetPart(1)
assert.Nil(t, err)
assert.Equal(t, uint8(1), part.PartNumber)
assert.Equal(t, "The Creed", part.Title)
}
func TestCatechism_GetPart_Invalid(t *testing.T) {
_, err := c.GetPart(0)
assert.Equal(t, "invalid part number", err.Error())
}
func TestCatechism_GetIntroduction(t *testing.T) {
intro, err := c.GetIntroduction(1)
assert.Nil(t, err)
assert.NotEmpty(t, intro.Sections)
}
func TestCatechism_GetIntroduction_Invalid(t *testing.T) {
_, err := c.GetIntroduction(0)
assert.Equal(t, "invalid part number", err.Error())
}
func TestCatechism_GetIntroductionSection(t *testing.T) {
s, err := c.GetIntroductionSection(1, 1)
assert.Nil(t, err)
assert.Equal(t, uint8(1), s.SectionNumber)
}
func TestCatechism_GetIntroductionSection_InvalidSection(t *testing.T) {
_, err := c.GetIntroductionSection(1, 100)
assert.Equal(t, "invalid section number", err.Error())
}
func TestCatechism_GetIntroductionParagraph(t *testing.T) {
p, err := c.GetIntroductionParagraph(1, 1, 1)
assert.Nil(t, err)
assert.Equal(t, uint8(1), p.ParagraphNumber)
assert.NotEmpty(t, p.Text)
}
func TestCatechism_GetArticle(t *testing.T) {
a, err := c.GetArticle(1, 1)
assert.Nil(t, err)
assert.Equal(t, uint8(1), a.ArticleNumber)
// Part 1, Article 1 should now be the First Article of the Creed — no longer
// the legacy "Introduction" stub and no longer the placeholder "Article 1".
assert.Equal(t, "I Believe in God, the Father Almighty, Creator of Heaven and Earth", a.Title)
assert.NotEmpty(t, a.Heading)
}
func TestCatechism_GetArticle_PreservesHeadingForCommandments(t *testing.T) {
// Part 3 Article 1 (First Commandment) should retain its full scripture
// heading on Article.Heading even though the navigable Title is short.
a, err := c.GetArticle(3, 1)
assert.Nil(t, err)
assert.Equal(t, "The First Commandment", a.Title)
assert.Contains(t, a.Heading, "THE FIRST COMMANDMENT")
}
func TestCatechism_GetArticle_InvalidPart(t *testing.T) {
_, err := c.GetArticle(0, 100)
assert.Equal(t, "invalid part number", err.Error())
}
func TestCatechism_GetArticle_InvalidArticle(t *testing.T) {
_, err := c.GetArticle(1, 100)
assert.Equal(t, "invalid article number", err.Error())
}
func TestCatechism_GetSection(t *testing.T) {
s, err := c.GetSection(1, 1, 1)
assert.Nil(t, err)
assert.Equal(t, uint8(1), s.SectionNumber)
// Every non-Intro article's first section is now the article's introduction.
assert.Equal(t, "Introduction", s.Title)
}
func TestCatechism_GetSection_InvalidPart(t *testing.T) {
_, err := c.GetSection(0, 100, 100)
assert.Equal(t, "invalid part number", err.Error())
}
func TestCatechism_GetSection_InvalidArticle(t *testing.T) {
_, err := c.GetSection(1, 100, 100)
assert.Equal(t, "invalid article number", err.Error())
}
func TestCatechism_GetSection_InvalidSection(t *testing.T) {
_, err := c.GetSection(1, 1, 100)
assert.Equal(t, "invalid section number", err.Error())
}
func TestCatechism_GetParagraph(t *testing.T) {
p, err := c.GetParagraph(1, 1, 1, 1)
assert.Nil(t, err)
assert.Equal(t, uint8(1), p.ParagraphNumber)
}
func TestCatechism_GetParagraph_InvalidPart(t *testing.T) {
_, err := c.GetParagraph(0, 100, 100, 100)
assert.Equal(t, "invalid part number", err.Error())
}
func TestCatechism_GetParagraph_InvalidArticle(t *testing.T) {
_, err := c.GetParagraph(1, 100, 100, 100)
assert.Equal(t, "invalid article number", err.Error())
}
func TestCatechism_GetParagraph_InvalidSection(t *testing.T) {
_, err := c.GetParagraph(1, 1, 100, 100)
assert.Equal(t, "invalid section number", err.Error())
}
func TestCatechism_GetParagraph_InvalidParagraph(t *testing.T) {
_, err := c.GetParagraph(1, 1, 1, 100)
assert.Equal(t, "invalid paragraph number", err.Error())
}
func TestCatechism_Search(t *testing.T) {
p := c.Search("I believe", 10)
assert.NotEmpty(t, p)
assert.Equal(t, "Part 4, Article 2, Section 3, Paragraph 1", p[0].String())
}
func TestCatechism_PartSummary(t *testing.T) {
assert.Len(t, c.PartSummary, 4)
// Article summaries should expose the new Heading field alongside the Title.
creed := c.PartSummary[0]
assert.Equal(t, "The Creed", creed.Title)
assert.NotEmpty(t, creed.Articles)
assert.NotEmpty(t, creed.Articles[0].Heading)
}