mirror of
https://github.com/peco/peco.git
synced 2026-09-10 07:16:29 -04:00
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
24 lines
874 B
Go
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)
|
|
}
|
|
}
|