summaryrefslogtreecommitdiff
path: root/src/pattern_test.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-01-11 01:47:46 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-01-11 01:53:51 +0900
commitca4bdfb4bd61e1cb9991146ac5b6bafbf5391072 (patch)
tree4bd992d751c4af2916f277640b4974f4b1622769 /src/pattern_test.go
parent4f4031443365659de357ad4da15af8b5e3245137 (diff)
downloadfzf-ca4bdfb4bd61e1cb9991146ac5b6bafbf5391072.tar.gz
Fix Transform result cache to speed up subsequent searches
Diffstat (limited to 'src/pattern_test.go')
-rw-r--r--src/pattern_test.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/pattern_test.go b/src/pattern_test.go
index a776e301..2635b6c7 100644
--- a/src/pattern_test.go
+++ b/src/pattern_test.go
@@ -86,19 +86,25 @@ func TestCaseSensitivity(t *testing.T) {
}
}
-func TestOrigText(t *testing.T) {
+func TestOrigTextAndTransformed(t *testing.T) {
strptr := func(str string) *string {
return &str
}
-
pattern := BuildPattern(MODE_EXTENDED, CASE_SMART, []Range{}, nil, []rune("jg"))
+ tokens := Tokenize(strptr("junegunn"), nil)
+ trans := Transform(tokens, []Range{Range{1, 1}})
+
for _, fun := range []func(*Chunk) []*Item{pattern.fuzzyMatch, pattern.extendedMatch} {
chunk := Chunk{
- &Item{text: strptr("junegunn"), origText: strptr("junegunn.choi")},
+ &Item{
+ text: strptr("junegunn"),
+ origText: strptr("junegunn.choi"),
+ transformed: trans},
}
matches := fun(&chunk)
if *matches[0].text != "junegunn" || *matches[0].origText != "junegunn.choi" ||
- matches[0].offsets[0][0] != 0 || matches[0].offsets[0][1] != 5 {
+ matches[0].offsets[0][0] != 0 || matches[0].offsets[0][1] != 5 ||
+ matches[0].transformed != trans {
t.Error("Invalid match result", matches)
}
}