github.com/rumpl/bof@v23.0.0-rc.2+incompatible/integration/internal/termtest/stripansi_test.go (about) 1 package termtest // import "github.com/docker/docker/integration/internal/termtest" 2 3 import ( 4 "testing" 5 6 "gotest.tools/v3/assert" 7 ) 8 9 func TestStripANSICommands(t *testing.T) { 10 for _, tt := range []struct{ input, want string }{ 11 { 12 input: "\x1b[2J\x1b[?25l\x1b[m\x1b[Hthis is fine\b\x1b]0;C:\\bin\\sh.exe\x00\a\x1b[?25h\x1b[Ht\x1b[1;13H\x1b[?25laccidents happen \b\x1b[?25h\x1b[Ht\x1b[1;29H", 13 want: "this is fineaccidents happen", 14 }, 15 { 16 input: "\x1b[2J\x1b[m\x1b[Hthis is fine\x1b]0;C:\\bin\\sh.exe\a\x1b[?25haccidents happen", 17 want: "this is fineaccidents happen", 18 }, 19 } { 20 t.Run("", func(t *testing.T) { 21 got, err := StripANSICommands(tt.input) 22 assert.NilError(t, err) 23 assert.DeepEqual(t, tt.want, got) 24 }) 25 } 26 }