goext/termext/termcolor_test.go

36 lines
1.1 KiB
Go
Raw Normal View History

2022-10-29 15:34:40 +02:00
package termext
import (
2023-08-14 16:32:39 +02:00
"gogs.mikescher.com/BlackForestBytes/goext/tst"
2022-10-29 15:34:40 +02:00
"math/rand"
"testing"
)
func init() {
rand.Seed(0)
}
func TestSupportsColors(t *testing.T) {
SupportsColors() // should not error
}
func TestColor(t *testing.T) {
2023-03-31 13:33:06 +02:00
tst.AssertEqual(t, Red("test"), "\033[31mtest\u001B[0m")
tst.AssertEqual(t, Green("test"), "\033[32mtest\u001B[0m")
tst.AssertEqual(t, Yellow("test"), "\033[33mtest\u001B[0m")
tst.AssertEqual(t, Blue("test"), "\033[34mtest\u001B[0m")
tst.AssertEqual(t, Purple("test"), "\033[35mtest\u001B[0m")
tst.AssertEqual(t, Cyan("test"), "\033[36mtest\u001B[0m")
tst.AssertEqual(t, Gray("test"), "\033[37mtest\u001B[0m")
tst.AssertEqual(t, White("test"), "\033[97mtest\u001B[0m")
2022-10-29 15:34:40 +02:00
2023-03-31 13:33:06 +02:00
tst.AssertEqual(t, CleanString(Red("test")), "test")
tst.AssertEqual(t, CleanString(Green("test")), "test")
tst.AssertEqual(t, CleanString(Yellow("test")), "test")
tst.AssertEqual(t, CleanString(Blue("test")), "test")
tst.AssertEqual(t, CleanString(Purple("test")), "test")
tst.AssertEqual(t, CleanString(Cyan("test")), "test")
tst.AssertEqual(t, CleanString(Gray("test")), "test")
tst.AssertEqual(t, CleanString(White("test")), "test")
2022-10-29 15:34:40 +02:00
}