1
0
mirror of https://github.com/mum4k/termdash.git synced 2025-04-25 13:48:50 +08:00

add tests for font modifier cell options

This commit is contained in:
“Carson 2020-11-13 02:46:39 -05:00
parent f501a14afa
commit 53530e7dc1
2 changed files with 38 additions and 0 deletions

View File

@ -141,6 +141,21 @@ func TestCellOptsToStyle(t *testing.T) {
opts: cell.Options{FgColor: cell.ColorWhite, BgColor: cell.ColorBlack},
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 {

View File

@ -15,6 +15,7 @@
package termbox
import (
"fmt"
"testing"
"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)
}
})
}
}