summaryrefslogtreecommitdiffstats
path: root/src/options_test.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-08-10 23:47:03 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-08-11 00:15:41 +0900
commitd0f2c00f9f0a2ded5a94703c30ea127b8f8cb847 (patch)
treeb30e5f42cec30491af9f2ab6270e2ba012f8682a /src/options_test.go
parent766427de0c04c64085c5ed907e3fdcc6124fa2dd (diff)
Fix --with-nth performance; use simpler regular expression
Related #317
Diffstat (limited to 'src/options_test.go')
-rw-r--r--src/options_test.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/options_test.go b/src/options_test.go
index e9884f2c..1f96f785 100644
--- a/src/options_test.go
+++ b/src/options_test.go
@@ -2,7 +2,6 @@ package fzf
import (
"fmt"
- "strings"
"testing"
"github.com/junegunn/fzf/src/curses"
@@ -21,7 +20,7 @@ func TestDelimiterRegex(t *testing.T) {
}
// Valid regex
delim = delimiterRegexp("[0-9]")
- if strings.Index(delim.regex.String(), "[0-9]") < 0 || delim.str != nil {
+ if delim.regex.String() != "[0-9]" || delim.str != nil {
t.Error(delim)
}
// Tab character
@@ -43,20 +42,25 @@ func TestDelimiterRegex(t *testing.T) {
func TestDelimiterRegexString(t *testing.T) {
delim := delimiterRegexp("*")
- tokens := strings.Split("-*--*---**---", *delim.str)
- if delim.regex != nil || tokens[0] != "-" || tokens[1] != "--" ||
- tokens[2] != "---" || tokens[3] != "" || tokens[4] != "---" {
+ tokens := Tokenize([]rune("-*--*---**---"), delim)
+ if delim.regex != nil ||
+ string(tokens[0].text) != "-*" ||
+ string(tokens[1].text) != "--*" ||
+ string(tokens[2].text) != "---*" ||
+ string(tokens[3].text) != "*" ||
+ string(tokens[4].text) != "---" {
t.Errorf("%s %s %d", delim, tokens, len(tokens))
}
}
func TestDelimiterRegexRegex(t *testing.T) {
delim := delimiterRegexp("--\\*")
- rx := delim.regex
- tokens := rx.FindAllString("-*--*---**---", -1)
+ tokens := Tokenize([]rune("-*--*---**---"), delim)
if delim.str != nil ||
- tokens[0] != "-*--*" || tokens[1] != "---*" || tokens[2] != "*---" {
- t.Errorf("%s %s %d", rx, tokens, len(tokens))
+ string(tokens[0].text) != "-*--*" ||
+ string(tokens[1].text) != "---*" ||
+ string(tokens[2].text) != "*---" {
+ t.Errorf("%s %d", tokens, len(tokens))
}
}