2015-01-01 19:49:30 +00:00
|
|
|
package fzf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2015-03-18 16:59:14 +00:00
|
|
|
|
2016-08-13 15:39:44 +00:00
|
|
|
"github.com/junegunn/fzf/src/util"
|
2015-01-01 19:49:30 +00:00
|
|
|
)
|
|
|
|
|
2016-08-18 17:39:32 +00:00
|
|
|
func TestStringPtr(t *testing.T) {
|
|
|
|
orig := []byte("\x1b[34mfoo")
|
|
|
|
text := []byte("\x1b[34mbar")
|
|
|
|
item := Item{origText: &orig, text: util.ToChars(text)}
|
|
|
|
if item.AsString(true) != "foo" || item.AsString(false) != string(orig) {
|
|
|
|
t.Fail()
|
2015-01-01 19:49:30 +00:00
|
|
|
}
|
2016-08-18 17:39:32 +00:00
|
|
|
if item.AsString(true) != "foo" {
|
|
|
|
t.Fail()
|
2015-01-01 19:49:30 +00:00
|
|
|
}
|
2016-08-18 17:39:32 +00:00
|
|
|
item.origText = nil
|
|
|
|
if item.AsString(true) != string(text) || item.AsString(false) != string(text) {
|
|
|
|
t.Fail()
|
2015-03-18 16:59:14 +00:00
|
|
|
}
|
|
|
|
}
|