Files

38 lines
1.5 KiB
Go

// Copyright (c) 2026 Storm Dragon
// SPDX-License-Identifier: GPL-3.0-or-later
package presentation
import (
"git.stormux.org/storm/fenrir/internal/screen"
"strings"
"testing"
)
func TestAttributeColorsStylesAndPythonFormat(t *testing.T) {
format := "fenrirFGColor|fenrirBGColor|fenrirBold|fenrirUnderline|fenrirItalics|fenrirBlink|fenrirReverse|fenrirStrikethrough|fenrirFontSize|fenrirFont"
a := screen.Attribute{Foreground: screen.ColorIndexed | 1, Background: screen.ColorIndexed | 4, Style: screen.Bold | screen.Underline | screen.Italic | screen.Blink | screen.Reverse | screen.Strike}
if got := Format_attributes(a, format); got != "red|blue|bold|underline|italic|blink|reverse|strikethrough|default|default" {
t.Fatal(got)
}
for _, trial := range []struct {
color uint32
want string
}{
{screen.ColorDefault, "default"}, {0, "#000000"}, {0x0c2238, "#0c2238"},
{screen.ColorIndexed | 7, "light gray"}, {screen.ColorIndexed | 9, "light red"},
{screen.ColorIndexed | 16, "#000000"}, {screen.ColorIndexed | 196, "#ff0000"},
{screen.ColorIndexed | 231, "#ffffff"}, {screen.ColorIndexed | 232, "#080808"}, {screen.ColorIndexed | 255, "#eeeeee"},
} {
if got := Format_attributes(screen.Attribute{Foreground: trial.color}, "fenrirFGColor"); got != trial.want {
t.Fatal(trial, got)
}
}
if got := Format_attributes(screen.Attribute{}, "fenrirBold fenrirUnderline fenrirBlink"); strings.TrimSpace(got) != "" {
t.Fatal(got)
}
if got := Format_attributes(a, ""); got != "" {
t.Fatal(got)
}
}