mirror of
https://github.com/gizak/termui.git
synced 2025-04-27 13:48:51 +08:00
testing easy case of no style
This commit is contained in:
parent
4d1aaf17a7
commit
70b8f7489a
@ -89,6 +89,12 @@ func processToken(token, previous string) (string, string) {
|
|||||||
|
|
||||||
func PrepareStyles(s string) []PreparedStyle {
|
func PrepareStyles(s string) []PreparedStyle {
|
||||||
items := []PreparedStyle{}
|
items := []PreparedStyle{}
|
||||||
|
tokens := strings.Split(s, "](")
|
||||||
|
if len(tokens) == 1 {
|
||||||
|
// easy case, not styled string
|
||||||
|
ps := PreparedStyle{s, ""}
|
||||||
|
return []PreparedStyle{ps}
|
||||||
|
}
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPrepareStyles(t *testing.T) {
|
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 {
|
if len(items) != 4 {
|
||||||
t.Fatal("wrong length", len(items))
|
t.Fatal("wrong length", len(items))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user