elvish/pkg/ui/mark_lines_test.go
Qi Xiao d3a38e0414 pkg/ui: Add utility for styling multiple regions in a text.
The code is factored from pkg/edit/highlight and is generally useful.
2021-02-27 23:05:42 +00:00

55 lines
923 B
Go

package ui
import (
"testing"
"src.elv.sh/pkg/tt"
)
func TestMarkLines(t *testing.T) {
stylesheet := RuneStylesheet{
'-': Inverse,
'x': Stylings(FgBlue, BgGreen),
}
tt.Test(t, tt.Fn("MarkLines", MarkLines), tt.Table{
tt.Args("foo bar foobar").Rets(T("foo bar foobar")),
tt.Args(
"foo bar foobar", stylesheet,
"--- xxx ------",
).Rets(
Concat(
T("foo", Inverse),
T(" "),
T("bar", FgBlue, BgGreen),
T(" "),
T("foobar", Inverse)),
),
tt.Args(
"foo bar foobar", stylesheet,
"---",
).Rets(
Concat(
T("foo", Inverse),
T(" bar foobar")),
),
tt.Args(
"plain1",
"plain2",
"foo bar foobar\n", stylesheet,
"--- xxx ------",
"plain3",
).Rets(
Concat(
T("plain1"),
T("plain2"),
T("foo", Inverse),
T(" "),
T("bar", FgBlue, BgGreen),
T(" "),
T("foobar", Inverse),
T("\n"),
T("plain3")),
),
})
}