示例#1
0
func TestChineseParser(t *testing.T) {
	type testDataEntry struct {
		input string
		ref   bible.RefRangeList
	}
	var testData = []testDataEntry{
		testDataEntry{"希伯來書4章14-16節", bible.SingleRangeRef(bible.Hebrews, 4, 14, 16)},
		testDataEntry{"詩篇73篇", bible.SingleRangeRef(bible.Psalm, 73, bible.ChapterBegin, bible.ChapterEnd)},
		testDataEntry{"希伯来书12章1-5节", bible.SingleRangeRef(bible.Hebrews, 12, 1, 5)},
	}
	for _, entry := range testData {
		match, offset, value := chineseParser.parse(entry.input)
		if !match || offset != len(entry.input) {
			t.Error(entry.input, match, offset)
		}
		if !reflect.DeepEqual(value, entry.ref) {
			t.Error(value, entry.ref)
		}
	}
}
示例#2
0
package brave

import (
	"fmt"
	"github.com/saintfish/bible.go/bible"
	"strconv"
)

var chinesePatterns = []struct {
	pattern string
	ref     bible.RefRangeList
}{
	{
		"希伯來書 12 章 1-5 節",
		bible.SingleRangeRef(bible.Hebrews, 12, 1, 5),
	},
	{
		"提摩太後書 3 章 1-5 , 10-17 節",
		bible.RefRangeList{
			bible.SingleRangeRef(bible.Timothy2, 3, 1, 5)[0],
			bible.SingleRangeRef(bible.Timothy2, 3, 10, 17)[0],
		},
	},
	{
		"羅馬書 8 章 14-17 節 , 24-26 節",
		bible.RefRangeList{
			bible.SingleRangeRef(bible.Romans, 8, 14, 17)[0],
			bible.SingleRangeRef(bible.Romans, 8, 24, 26)[0],
		},
	},
	{