mirror of
https://github.com/mum4k/termdash.git
synced 2025-04-28 13:48:51 +08:00
add tests for font modifier cell options
This commit is contained in:
parent
f501a14afa
commit
53530e7dc1
@ -141,6 +141,21 @@ func TestCellOptsToStyle(t *testing.T) {
|
|||||||
opts: cell.Options{FgColor: cell.ColorWhite, BgColor: cell.ColorBlack},
|
opts: cell.Options{FgColor: cell.ColorWhite, BgColor: cell.ColorBlack},
|
||||||
want: tcell.StyleDefault.Foreground(tcell.Color23).Background(tcell.Color16),
|
want: tcell.StyleDefault.Foreground(tcell.Color23).Background(tcell.Color16),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
colorMode: terminalapi.ColorModeNormal,
|
||||||
|
opts: cell.Options{Bold: true},
|
||||||
|
want: tcell.StyleDefault.Bold(true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
colorMode: terminalapi.ColorModeNormal,
|
||||||
|
opts: cell.Options{Italic: true},
|
||||||
|
want: tcell.StyleDefault.Italic(true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
colorMode: terminalapi.ColorModeNormal,
|
||||||
|
opts: cell.Options{Underline: true},
|
||||||
|
want: tcell.StyleDefault.Underline(true),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package termbox
|
package termbox
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/mum4k/termdash/cell"
|
"github.com/mum4k/termdash/cell"
|
||||||
@ -48,3 +49,25 @@ func TestCellColor(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCellFontModifier(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
opt cell.Options
|
||||||
|
want tbx.Attribute
|
||||||
|
}{
|
||||||
|
{cell.Options{Bold: true}, tbx.AttrBold},
|
||||||
|
{cell.Options{Underline: true}, tbx.AttrUnderline},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range tests {
|
||||||
|
t.Run(fmt.Sprintf("%v", tc.opt), func(t *testing.T) {
|
||||||
|
got, err := cellOptsToFg(&tc.opt)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("cellOptsToFg(%v) failed: %s", tc.opt, err)
|
||||||
|
}
|
||||||
|
if got != tc.want {
|
||||||
|
t.Errorf("cellOptsToFg(%v) => got %v, want %v", tc.opt, got, tc.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user