···11import bible_search
22import gleeunit
33+import gleeunit/should
3445pub fn main() -> Nil {
56 gleeunit.main()
···89// gleeunit test functions end in `_test`
910pub fn parse_reference_test() {
1011 let ref = bible_search.parse_reference("FIRST KINGS 10 10")
1212+ should.be_ok(ref)
1313+1114 let expected_ref =
1215 Ok(bible_search.Reference(book: "FIRST KINGS", chapter: 10, verse: 10))
13161414- assert Ok(ref) == Ok(expected_ref)
1717+ should.be_true(ref == expected_ref)
1518}
16191720pub fn parse_reference_single_word_book_test() {
1821 let ref = bible_search.parse_reference("GENESIS 1 1")
2222+ should.be_ok(ref)
2323+1924 let expected_ref =
2025 Ok(bible_search.Reference(book: "GENESIS", chapter: 1, verse: 1))
21262222- assert Ok(ref) == Ok(expected_ref)
2727+ should.be_true(ref == expected_ref)
2328}
24292530pub fn parse_reference_invalid_chapter_test() {
2631 let ref = bible_search.parse_reference("GENESIS abc 1")
3232+ should.be_error(ref)
3333+2734 let expected_error = Error("Invalid chapter: abc")
28352929- assert ref == expected_error
3636+ should.be_true(ref == expected_error)
3037}
31383239pub fn parse_reference_invalid_verse_test() {
3340 let ref = bible_search.parse_reference("GENESIS 1 xyz")
4141+ should.be_error(ref)
3442 let expected_error = Error("Invalid verse: xyz")
35433636- assert ref == expected_error
4444+ should.be_true(ref == expected_error)
3745}
38463947pub fn parse_reference_too_few_parts_test() {
4048 let ref = bible_search.parse_reference("GENESIS 1")
4949+ should.be_error(ref)
4150 let expected_error = Error("invalid parse")
42514343- assert ref == expected_error
5252+ should.be_true(ref == expected_error)
4453}
45544655pub fn parse_reference_too_many_parts_test() {
4756 let ref = bible_search.parse_reference("SONG OF SOLOMON 1 1")
5757+ should.be_error(ref)
4858 let expected_error = Error("invalid parse")
49595050- assert ref == expected_error
6060+ should.be_true(ref == expected_error)
5161}
52625363pub fn parse_reference_lowercase_book_test() {
5464 let ref = bible_search.parse_reference("genesis 1 1")
6565+ should.be_ok(ref)
6666+5567 let expected_ref =
5668 Ok(bible_search.Reference(book: "GENESIS", chapter: 1, verse: 1))
57695858- assert Ok(ref) == Ok(expected_ref)
7070+ should.be_true(ref == expected_ref)
7171+}
7272+7373+pub fn bible_scan_found_verse_test() {
7474+ let bible =
7575+ "THE BOOK OF GENESIS
7676+7777+CHAPTER 1
7878+7979+1 In the beginning God created the heaven and the earth.
8080+2 And the earth was without form, and void; and darkness was upon the face of the deep."
8181+8282+ let ref = bible_search.Reference(book: "GENESIS", chapter: 1, verse: 1)
8383+ let result = bible_search.bible_scan(reference: ref, bible: bible)
8484+8585+ should.be_true(
8686+ result.verse == Ok("In the beginning God created the heaven and the earth."),
8787+ )
8888+}
8989+9090+pub fn bible_scan_verse_not_found_test() {
9191+ let bible =
9292+ "THE BOOK OF GENESIS
9393+9494+CHAPTER 1
9595+9696+1 In the beginning God created the heaven and the earth."
9797+9898+ let ref = bible_search.Reference(book: "GENESIS", chapter: 1, verse: 99)
9999+ let result = bible_search.bible_scan(reference: ref, bible: bible)
100100+101101+ should.be_true(result.verse == Error("Verse not found"))
102102+}
103103+104104+pub fn bible_scan_book_not_found_test() {
105105+ let bible =
106106+ "THE BOOK OF GENESIS
107107+108108+CHAPTER 1
109109+110110+1 In the beginning God created the heaven and the earth."
111111+112112+ let ref = bible_search.Reference(book: "EXODUS", chapter: 1, verse: 1)
113113+ let result = bible_search.bible_scan(reference: ref, bible: bible)
114114+115115+ should.be_true(result.verse == Error("Verse not found"))
116116+}
117117+118118+pub fn bible_scan_chapter_not_found_test() {
119119+ let bible =
120120+ "THE BOOK OF GENESIS
121121+122122+CHAPTER 1
123123+124124+1 In the beginning God created the heaven and the earth."
125125+126126+ let ref = bible_search.Reference(book: "GENESIS", chapter: 99, verse: 1)
127127+ let result = bible_search.bible_scan(reference: ref, bible: bible)
128128+129129+ should.be_true(result.verse == Error("Verse not found"))
130130+}
131131+132132+pub fn bible_scan_multiple_verses_test() {
133133+ let bible =
134134+ "THE BOOK OF GENESIS
135135+136136+CHAPTER 1
137137+138138+1 In the beginning God created the heaven and the earth.
139139+2 And the earth was without form, and void; and darkness was upon the face of the deep.
140140+3 And God said, Let there be light: and there was light."
141141+142142+ let ref = bible_search.Reference(book: "GENESIS", chapter: 1, verse: 2)
143143+ let result = bible_search.bible_scan(reference: ref, bible: bible)
144144+145145+ should.be_true(
146146+ result.verse
147147+ == Ok(
148148+ "And the earth was without form, and void; and darkness was upon the face of the deep.",
149149+ ),
150150+ )
59151}