0
0

fix broken tests

This commit is contained in:
Marty Schoch 2014-08-28 14:57:27 -04:00
parent 949accc3e4
commit e6ee7a11c4
3 changed files with 11 additions and 3 deletions

View File

@ -175,7 +175,7 @@ func TestSimpleFragmenter(t *testing.T) {
},
}
fragmenter := NewSimpleFragmenter()
fragmenter := NewSimpleFragmenterWithSize(100)
for _, test := range tests {
fragments := fragmenter.Fragment(test.orig, test.ot)
if !reflect.DeepEqual(fragments, test.fragments) {

View File

@ -116,7 +116,14 @@ func (s *SimpleHighlighter) BestFragmentsInField(dm *DocumentMatch, doc *documen
// now that we have the best fragments, we can format them
formattedFragments := make([]string, len(bestFragments))
for i, fragment := range bestFragments {
formattedFragments[i] = s.sep + s.formatter.Format(fragment, dm.Locations[field]) + s.sep
formattedFragments[i] = ""
if fragment.start != 0 {
formattedFragments[i] += s.sep
}
formattedFragments[i] += s.formatter.Format(fragment, dm.Locations[field])
if fragment.end != len(fragment.orig) {
formattedFragments[i] += s.sep
}
}
if dm.Fragments == nil {

View File

@ -42,7 +42,7 @@ func TestSimpleHighlighter(t *testing.T) {
},
}
expectedFragment := DEFAULT_SEPARATOR + "the " + DEFAULT_ANSI_HIGHLIGHT + "quick" + reset + " brown " + DEFAULT_ANSI_HIGHLIGHT + "fox" + reset + " jumps over the lazy dog" + DEFAULT_SEPARATOR
expectedFragment := "the " + DEFAULT_ANSI_HIGHLIGHT + "quick" + reset + " brown " + DEFAULT_ANSI_HIGHLIGHT + "fox" + reset + " jumps over the lazy dog"
doc := document.NewDocument("a").AddField(document.NewTextField("desc", []uint64{}, []byte("the quick brown fox jumps over the lazy dog")))
fragment := highlighter.BestFragmentInField(&docMatch, doc, "desc")
@ -143,6 +143,7 @@ Etiam vel augue vel nisl commodo suscipit et ac nisl. Quisque eros diam, porttit
}
highlighter := NewSimpleHighlighter()
highlighter.SetFragmenter(NewSimpleFragmenterWithSize(100))
fragments := highlighter.BestFragmentsInField(&docMatch, doc, "full", 5)
if !reflect.DeepEqual(fragments, expectedFragments) {