Fix panic when pattern occurs after 2^15-th column

Fix #666
This commit is contained in:
Junegunn Choi
2016-09-21 01:15:06 +09:00
parent 37f43fbb35
commit 791076d366
2 changed files with 18 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
package algo
import (
"math"
"sort"
"strings"
"testing"
@@ -154,3 +155,12 @@ func TestEmptyPattern(t *testing.T) {
assertMatch(t, SuffixMatch, true, dir, "foobar", "", 6, 6, 0)
}
}
func TestLongString(t *testing.T) {
bytes := make([]byte, math.MaxUint16*2)
for i := range bytes {
bytes[i] = 'x'
}
bytes[math.MaxUint16] = 'z'
assertMatch(t, FuzzyMatchV2, true, true, string(bytes), "zx", math.MaxUint16, math.MaxUint16+2, scoreMatch*2+bonusConsecutive)
}