mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-11-14 12:15:06 +08:00
26 lines
633 B
Go
26 lines
633 B
Go
|
package notifications
|
||
|
|
||
|
import "testing"
|
||
|
|
||
|
func Test_stripAnsiColorsValid(t *testing.T) {
|
||
|
|
||
|
coloredStr := "\x1b[0133myellow\x1b[0m" // 33 == yellow
|
||
|
nonColoredStr := "yellow"
|
||
|
|
||
|
s := stripAnsiColors(coloredStr)
|
||
|
if s != nonColoredStr {
|
||
|
t.Errorf("stripAnsiColors() stripped %q different from %q", coloredStr, nonColoredStr)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func Test_stripAnsiColorsInvalid(t *testing.T) {
|
||
|
|
||
|
coloredStr := "\x1b[01AAmyellow\x1b[0m" // AA not a real color
|
||
|
nonColoredStr := "yellow"
|
||
|
|
||
|
s := stripAnsiColors(coloredStr)
|
||
|
if s == nonColoredStr {
|
||
|
t.Errorf("stripAnsiColors() stripped %q should be different from %q", coloredStr, nonColoredStr)
|
||
|
}
|
||
|
}
|