stripansi_test.go 745 B

1234567891011121314151617181920212223242526
  1. package termtest // import "github.com/docker/docker/integration/internal/termtest"
  2. import (
  3. "testing"
  4. "gotest.tools/v3/assert"
  5. )
  6. func TestStripANSICommands(t *testing.T) {
  7. for _, tt := range []struct{ input, want string }{
  8. {
  9. 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",
  10. want: "this is fineaccidents happen",
  11. },
  12. {
  13. input: "\x1b[2J\x1b[m\x1b[Hthis is fine\x1b]0;C:\\bin\\sh.exe\a\x1b[?25haccidents happen",
  14. want: "this is fineaccidents happen",
  15. },
  16. } {
  17. t.Run("", func(t *testing.T) {
  18. got, err := StripANSICommands(tt.input)
  19. assert.NilError(t, err)
  20. assert.DeepEqual(t, tt.want, got)
  21. })
  22. }
  23. }