···
3
+
import gleeunit/should
···
// gleeunit test functions end in `_test`
pub fn parse_reference_test() {
let ref = bible_search.parse_reference("FIRST KINGS 10 10")
Ok(bible_search.Reference(book: "FIRST KINGS", chapter: 10, verse: 10))
14
-
assert Ok(ref) == Ok(expected_ref)
17
+
should.be_true(ref == expected_ref)
pub fn parse_reference_single_word_book_test() {
let ref = bible_search.parse_reference("GENESIS 1 1")
Ok(bible_search.Reference(book: "GENESIS", chapter: 1, verse: 1))
22
-
assert Ok(ref) == Ok(expected_ref)
27
+
should.be_true(ref == expected_ref)
pub fn parse_reference_invalid_chapter_test() {
let ref = bible_search.parse_reference("GENESIS abc 1")
32
+
should.be_error(ref)
let expected_error = Error("Invalid chapter: abc")
29
-
assert ref == expected_error
36
+
should.be_true(ref == expected_error)
pub fn parse_reference_invalid_verse_test() {
let ref = bible_search.parse_reference("GENESIS 1 xyz")
41
+
should.be_error(ref)
let expected_error = Error("Invalid verse: xyz")
36
-
assert ref == expected_error
44
+
should.be_true(ref == expected_error)
pub fn parse_reference_too_few_parts_test() {
let ref = bible_search.parse_reference("GENESIS 1")
49
+
should.be_error(ref)
let expected_error = Error("invalid parse")
43
-
assert ref == expected_error
52
+
should.be_true(ref == expected_error)
pub fn parse_reference_too_many_parts_test() {
let ref = bible_search.parse_reference("SONG OF SOLOMON 1 1")
57
+
should.be_error(ref)
let expected_error = Error("invalid parse")
50
-
assert ref == expected_error
60
+
should.be_true(ref == expected_error)
pub fn parse_reference_lowercase_book_test() {
let ref = bible_search.parse_reference("genesis 1 1")
Ok(bible_search.Reference(book: "GENESIS", chapter: 1, verse: 1))
58
-
assert Ok(ref) == Ok(expected_ref)
70
+
should.be_true(ref == expected_ref)
73
+
pub fn bible_scan_found_verse_test() {
75
+
"THE BOOK OF GENESIS
79
+
1 In the beginning God created the heaven and the earth.
80
+
2 And the earth was without form, and void; and darkness was upon the face of the deep."
82
+
let ref = bible_search.Reference(book: "GENESIS", chapter: 1, verse: 1)
83
+
let result = bible_search.bible_scan(reference: ref, bible: bible)
86
+
result.verse == Ok("In the beginning God created the heaven and the earth."),
90
+
pub fn bible_scan_verse_not_found_test() {
92
+
"THE BOOK OF GENESIS
96
+
1 In the beginning God created the heaven and the earth."
98
+
let ref = bible_search.Reference(book: "GENESIS", chapter: 1, verse: 99)
99
+
let result = bible_search.bible_scan(reference: ref, bible: bible)
101
+
should.be_true(result.verse == Error("Verse not found"))
104
+
pub fn bible_scan_book_not_found_test() {
106
+
"THE BOOK OF GENESIS
110
+
1 In the beginning God created the heaven and the earth."
112
+
let ref = bible_search.Reference(book: "EXODUS", chapter: 1, verse: 1)
113
+
let result = bible_search.bible_scan(reference: ref, bible: bible)
115
+
should.be_true(result.verse == Error("Verse not found"))
118
+
pub fn bible_scan_chapter_not_found_test() {
120
+
"THE BOOK OF GENESIS
124
+
1 In the beginning God created the heaven and the earth."
126
+
let ref = bible_search.Reference(book: "GENESIS", chapter: 99, verse: 1)
127
+
let result = bible_search.bible_scan(reference: ref, bible: bible)
129
+
should.be_true(result.verse == Error("Verse not found"))
132
+
pub fn bible_scan_multiple_verses_test() {
134
+
"THE BOOK OF GENESIS
138
+
1 In the beginning God created the heaven and the earth.
139
+
2 And the earth was without form, and void; and darkness was upon the face of the deep.
140
+
3 And God said, Let there be light: and there was light."
142
+
let ref = bible_search.Reference(book: "GENESIS", chapter: 1, verse: 2)
143
+
let result = bible_search.bible_scan(reference: ref, bible: bible)
148
+
"And the earth was without form, and void; and darkness was upon the face of the deep.",