peco.peco/matchers_test.go
Daisuke Maki b22cb7b8f6 Tweak so that we save the control sequence in Match.Buffer()
Using #167 as a basis, we save the original control sequence, and
only strip it when we display to peco. This also has the added
benefit that Match.Line() is used for matching, so we can effectively
match the line w/o the control sequence
2014-07-24 20:36:17 +09:00

24 lines
874 B
Go

package peco
import "testing"
// some little test to validate ansi strips function
func TestANSIColorStrip(t *testing.T) {
test := stripANSISequence("this is not a pipe")
if test != "this is not a pipe" {
t.Errorf("expected String = 'this is not a pipe', got '%s'", test)
}
test = stripANSISequence(" [01;34helloWorld [0m")
if test != " [01;34helloWorld [0m" {
t.Errorf("expected String = ' [01;34mhelloWorld [0m', got '%s'", test)
}
test = stripANSISequence("\x1b[01;34mthe answer to life is \x1b[0;42m42")
if test != "the answer to life is 42" {
t.Errorf("expected String = 'the answer to life is 42' , got '%s'", test)
}
test = stripANSISequence("x1b[01;34mthe answer to life is x1b[0;42m42")
if test != "x1b[01;34mthe answer to life is x1b[0;42m42" {
t.Errorf("expected String = 'x1b[01;34mthe answer to life is x1b[0;42m42' , got '%s'", test)
}
}