Fix "PR c++/92804 ICE trying to use concept as a nested-name-specifier"
[official-gcc.git] / libgo / go / net / pipe_test.go
blob9cc24148ca26fe0173412ae378b38c51fa47b1a8
1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package net_test
7 import (
8 "io"
9 "net"
10 "testing"
11 "time"
13 "golang.org/x/net/nettest"
16 func TestPipe(t *testing.T) {
17 nettest.TestConn(t, func() (c1, c2 net.Conn, stop func(), err error) {
18 c1, c2 = net.Pipe()
19 stop = func() {
20 c1.Close()
21 c2.Close()
23 return
27 func TestPipeCloseError(t *testing.T) {
28 c1, c2 := net.Pipe()
29 c1.Close()
31 if _, err := c1.Read(nil); err != io.ErrClosedPipe {
32 t.Errorf("c1.Read() = %v, want io.ErrClosedPipe", err)
34 if _, err := c1.Write(nil); err != io.ErrClosedPipe {
35 t.Errorf("c1.Write() = %v, want io.ErrClosedPipe", err)
37 if err := c1.SetDeadline(time.Time{}); err != io.ErrClosedPipe {
38 t.Errorf("c1.SetDeadline() = %v, want io.ErrClosedPipe", err)
40 if _, err := c2.Read(nil); err != io.EOF {
41 t.Errorf("c2.Read() = %v, want io.EOF", err)
43 if _, err := c2.Write(nil); err != io.ErrClosedPipe {
44 t.Errorf("c2.Write() = %v, want io.ErrClosedPipe", err)
46 if err := c2.SetDeadline(time.Time{}); err != io.ErrClosedPipe {
47 t.Errorf("c2.SetDeadline() = %v, want io.ErrClosedPipe", err)