-
Notifications
You must be signed in to change notification settings - Fork 2
/
parse_test.go
89 lines (71 loc) · 2.35 KB
/
parse_test.go
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
package romanus
import (
"github.com/stretchr/testify/assert"
"testing"
)
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)
}
func TestCatechism_GetPart_Invalid(t *testing.T) {
_, err := c.GetPart(0)
assert.Equal(t, "invalid part number", err.Error())
}
func TestCatechism_GetArticle(t *testing.T) {
a, err := c.GetArticle(1, 1)
assert.Nil(t, err)
assert.Equal(t, uint8(1), a.ArticleNumber)
}
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)
}
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 3, Section 4, Paragraph 1", p[0].String())
}