-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathctxio_other_wrap_test.go
More file actions
65 lines (47 loc) · 1.08 KB
/
ctxio_other_wrap_test.go
File metadata and controls
65 lines (47 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//go:build solaris
package ctxio
import (
"os"
"testing"
)
func TestWrapFilePipe(t *testing.T) {
t.Parallel()
r, w, err := os.Pipe()
if err != nil {
t.Fatalf("os.Pipe: %v", err)
}
defer r.Close()
defer w.Close()
cio, err := WrapFile(r)
if err != nil {
t.Fatalf("WrapFile(pipe): %v", err)
}
defer cio.Close()
if _, ok := cio.(*selectIO); !ok {
t.Errorf("WrapFile(pipe) = %T, want *selectIO", cio)
}
}
func TestWrapConnTCP(t *testing.T) {
t.Parallel()
conn, _ := activeConns(t, "tcp4", "127.0.0.1:0")
cio, err := WrapConn(conn)
if err != nil {
t.Fatalf("WrapConn(tcp): %v", err)
}
defer cio.Close()
if _, ok := cio.(*selectIO); !ok {
t.Errorf("WrapConn(tcp) = %T, want *selectIO", cio)
}
}
func TestWrapConnDeadlineFallback(t *testing.T) {
t.Parallel()
conn, _ := activeConns(t, "tcp4", "127.0.0.1:0")
cio, err := WrapConn(deadlinerOnlyConn{Conn: conn})
if err != nil {
t.Fatalf("WrapConn(deadlinerOnlyConn): %v", err)
}
defer cio.Close()
if _, ok := cio.(*deadlineIO); !ok {
t.Errorf("WrapConn(deadlinerOnlyConn) = %T, want *deadlineIO", cio)
}
}