Fix chapter test.
This test content may be moved to a different function.
This commit is contained in:
parent
c0c199320c
commit
e6e4974ad0
1 changed files with 18 additions and 34 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package bible_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
|
@ -10,6 +11,11 @@ import (
|
|||
"go.destrealm.net/vfs"
|
||||
)
|
||||
|
||||
const (
|
||||
Jude5 string = `Although you are fully aware of this, I want to remind you that after Jesus had delivered His people out of the land of Egypt, He destroyed those who did not believe.`
|
||||
Jude6 string = `And the angels who did not stay within their own domain but abandoned their proper dwelling—these He has kept in eternal chains under darkness, bound for judgment on that great day.`
|
||||
)
|
||||
|
||||
func loadScripture(s string) (*bible.Chapter, error) {
|
||||
st, err := os.Stat(s)
|
||||
if err != nil {
|
||||
|
|
@ -37,45 +43,23 @@ func loadScripture(s string) (*bible.Chapter, error) {
|
|||
}
|
||||
|
||||
func Test_ChapterJSON(t *testing.T) {
|
||||
ch, err := loadScripture("../../data/translations/bsb/GEN/1/chapter.json")
|
||||
if err != nil {
|
||||
testJSON := &bytes.Buffer{}
|
||||
testJSON.WriteString(`{"numberOfVerses": 25, "chapter": {"number": 1, "content": [{"type": "verse", "number": 5, "content": ["Although you are fully aware of this, I want to remind you that after Jesus", {"noteId": 0}, "had delivered His people out of the land of Egypt, He destroyed those who did not believe."]}, {"type": "verse", "number": 6, "content": ["And the angels who did not stay within their own domain but abandoned their proper dwelling\u2014these He has kept in eternal chains under darkness, bound for judgment on that great day."]}]}}`)
|
||||
|
||||
c := &bible.Chapter{}
|
||||
if err := json.Unmarshal(testJSON.Bytes(), c); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
/*fmt.Println(ch)
|
||||
fmt.Println(ch.ChapterDecl)
|
||||
fmt.Println("length:", len(ch.ChapterDecl.Content))
|
||||
|
||||
fmt.Println(ch.NumVerses, ch.ChapterDecl.Number)*/
|
||||
|
||||
if ch.NumVerses != 31 {
|
||||
t.Errorf("expected 31 verses in Genesis 1, got %d", ch.NumVerses)
|
||||
}
|
||||
if ch.ChapterDecl.Number != 1 {
|
||||
t.Errorf("metadata should report chapter '1'; received: %d", ch.ChapterDecl.Number)
|
||||
vv := c.FilterVerses(5, 5)
|
||||
if vv.String() != Jude5 {
|
||||
t.Error("Jude 5 did not match as expected:", vv.String())
|
||||
}
|
||||
|
||||
/*for _, c := range ch.ChapterDecl.Content {
|
||||
if c.IsVerse {
|
||||
fmt.Print(c.Number, " ")
|
||||
if len(c.Content) > 0 {
|
||||
for _, c1 := range c.Content {
|
||||
if len(c1.Text) > 0 {
|
||||
fmt.Print(c1.Text, " ")
|
||||
}
|
||||
if c1.IsLineBreak {
|
||||
t.Fatal("line break")
|
||||
fmt.Print("\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if c.IsLineBreak {
|
||||
fmt.Print("\n")
|
||||
}
|
||||
}*/
|
||||
|
||||
t.Error(".")
|
||||
vv = c.FilterVerses(6, 6)
|
||||
if vv.String() != Jude6 {
|
||||
t.Error("Jude 6 did not match as expected:", vv.String())
|
||||
}
|
||||
}
|
||||
|
||||
func Test_VerseFilter(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue