mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-07 09:17:26 -08:00
26 lines
569 B
Go
26 lines
569 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestLenWithoutAnsi(t *testing.T) {
|
||
|
cases := []struct {
|
||
|
Text string
|
||
|
ShellName string
|
||
|
Expected int
|
||
|
}{
|
||
|
{Text: "%{\x1b[44m%}hello%{\x1b[0m%}", ShellName: zsh, Expected: 5},
|
||
|
{Text: "\x1b[44mhello\x1b[0m", ShellName: pwsh, Expected: 5},
|
||
|
{Text: "\\[\x1b[44m\\]hello\\[\x1b[0m\\]", ShellName: bash, Expected: 5},
|
||
|
}
|
||
|
for _, tc := range cases {
|
||
|
a := ansiFormats{}
|
||
|
a.init(tc.ShellName)
|
||
|
strippedLength := a.lenWithoutANSI(tc.Text)
|
||
|
assert.Equal(t, 5, strippedLength)
|
||
|
}
|
||
|
}
|