Reuse indexes for D&D citation validation
This commit is contained in:
@@ -7,8 +7,12 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
)
|
||||
|
||||
func TestCitedText(t *testing.T) {
|
||||
func TestCitationResolver(t *testing.T) {
|
||||
doc := citationDocument()
|
||||
resolver, err := NewCitationResolver(doc)
|
||||
if err != nil {
|
||||
t.Fatalf("NewCitationResolver() error = %v", err)
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
refs []source.SourceRef
|
||||
@@ -51,7 +55,7 @@ func TestCitedText(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
beforeUnits := append([]source.SourceUnit(nil), doc.Units...)
|
||||
refs := append([]source.SourceRef(nil), test.refs...)
|
||||
got, err := CitedText(doc, refs)
|
||||
got, err := resolver.CitedText(refs)
|
||||
if (err != nil) != test.wantErr {
|
||||
t.Fatalf("CitedText() error = %v, want error = %t", err, test.wantErr)
|
||||
}
|
||||
@@ -65,9 +69,9 @@ func TestCitedText(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCitedTextRejectsNilDocument(t *testing.T) {
|
||||
if _, err := CitedText(nil, nil); err == nil {
|
||||
t.Fatal("CitedText() error = nil, want nil-document error")
|
||||
func TestNewCitationResolverRejectsNilDocument(t *testing.T) {
|
||||
if _, err := NewCitationResolver(nil); err == nil {
|
||||
t.Fatal("NewCitationResolver() error = nil, want nil-document error")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user