fzf/src/options_test.go

38 lines
1.1 KiB
Go
Raw Normal View History

2015-01-01 19:49:30 +00:00
package fzf
import "testing"
func TestDelimiterRegex(t *testing.T) {
rx := delimiterRegexp("*")
tokens := rx.FindAllString("-*--*---**---", -1)
if tokens[0] != "-*" || tokens[1] != "--*" || tokens[2] != "---*" ||
tokens[3] != "*" || tokens[4] != "---" {
t.Errorf("%s %s %d", rx, tokens, len(tokens))
}
}
func TestSplitNth(t *testing.T) {
{
ranges := splitNth("..")
if len(ranges) != 1 ||
2015-01-11 18:01:24 +00:00
ranges[0].begin != rangeEllipsis ||
ranges[0].end != rangeEllipsis {
2015-01-01 19:49:30 +00:00
t.Errorf("%s", ranges)
}
}
{
ranges := splitNth("..3,1..,2..3,4..-1,-3..-2,..,2,-2")
if len(ranges) != 8 ||
2015-01-11 18:01:24 +00:00
ranges[0].begin != rangeEllipsis || ranges[0].end != 3 ||
ranges[1].begin != 1 || ranges[1].end != rangeEllipsis ||
2015-01-01 19:49:30 +00:00
ranges[2].begin != 2 || ranges[2].end != 3 ||
ranges[3].begin != 4 || ranges[3].end != -1 ||
ranges[4].begin != -3 || ranges[4].end != -2 ||
2015-01-11 18:01:24 +00:00
ranges[5].begin != rangeEllipsis || ranges[5].end != rangeEllipsis ||
2015-01-01 19:49:30 +00:00
ranges[6].begin != 2 || ranges[6].end != 2 ||
ranges[7].begin != -2 || ranges[7].end != -2 {
t.Errorf("%s", ranges)
}
}
}