isatty_windows_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // +build windows
  2. package isatty
  3. import (
  4. "testing"
  5. )
  6. func TestCygwinPipeName(t *testing.T) {
  7. tests := []struct {
  8. name string
  9. result bool
  10. }{
  11. {``, false},
  12. {`\msys-`, false},
  13. {`\cygwin-----`, false},
  14. {`\msys-x-PTY5-pty1-from-master`, false},
  15. {`\cygwin-x-PTY5-from-master`, false},
  16. {`\cygwin-x-pty2-from-toaster`, false},
  17. {`\cygwin--pty2-from-master`, false},
  18. {`\\cygwin-x-pty2-from-master`, false},
  19. {`\cygwin-x-pty2-from-master-`, true}, // for the feature
  20. {`\cygwin-e022582115c10879-pty4-from-master`, true},
  21. {`\msys-e022582115c10879-pty4-to-master`, true},
  22. {`\cygwin-e022582115c10879-pty4-to-master`, true},
  23. {`\Device\NamedPipe\cygwin-e022582115c10879-pty4-from-master`, true},
  24. {`\Device\NamedPipe\msys-e022582115c10879-pty4-to-master`, true},
  25. {`Device\NamedPipe\cygwin-e022582115c10879-pty4-to-master`, false},
  26. }
  27. for _, test := range tests {
  28. want := test.result
  29. got := isCygwinPipeName(test.name)
  30. if want != got {
  31. t.Fatalf("isatty(%q): got %v, want %v:", test.name, got, want)
  32. }
  33. }
  34. }