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