1
0
mirror of https://github.com/gizak/termui.git synced 2025-04-24 13:48:50 +08:00

testing easy case of no style

This commit is contained in:
Andrew Arrow 2022-11-07 04:24:12 -08:00
parent 4d1aaf17a7
commit 70b8f7489a
2 changed files with 11 additions and 1 deletions

View File

@ -89,6 +89,12 @@ func processToken(token, previous string) (string, string) {
func PrepareStyles(s string) []PreparedStyle {
items := []PreparedStyle{}
tokens := strings.Split(s, "](")
if len(tokens) == 1 {
// easy case, not styled string
ps := PreparedStyle{s, ""}
return []PreparedStyle{ps}
}
return items
}

View File

@ -6,7 +6,11 @@ import (
)
func TestPrepareStyles(t *testing.T) {
items := PrepareStyles("test [blue](fg:blue,bg:white,mod:bold) and [red](fg:red)")
items := PrepareStyles("test no style")
if len(items) != 1 {
t.Fatal("wrong length", len(items))
}
items = PrepareStyles("test [blue](fg:blue,bg:white,mod:bold) and [red](fg:red)")
if len(items) != 4 {
t.Fatal("wrong length", len(items))
}