* gcc-interface/decl.c (warn_on_field_placement): Issue the warning
[official-gcc.git] / libgo / go / net / fd_posix_test.go
blob85711ef1b70df50dcd60010a408c1672a6ea8d2f
1 // Copyright 2012 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 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
7 package net
9 import (
10 "io"
11 "syscall"
12 "testing"
15 var eofErrorTests = []struct {
16 n int
17 err error
18 fd *netFD
19 expected error
21 {100, nil, &netFD{sotype: syscall.SOCK_STREAM}, nil},
22 {100, io.EOF, &netFD{sotype: syscall.SOCK_STREAM}, io.EOF},
23 {100, errClosing, &netFD{sotype: syscall.SOCK_STREAM}, errClosing},
24 {0, nil, &netFD{sotype: syscall.SOCK_STREAM}, io.EOF},
25 {0, io.EOF, &netFD{sotype: syscall.SOCK_STREAM}, io.EOF},
26 {0, errClosing, &netFD{sotype: syscall.SOCK_STREAM}, errClosing},
28 {100, nil, &netFD{sotype: syscall.SOCK_DGRAM}, nil},
29 {100, io.EOF, &netFD{sotype: syscall.SOCK_DGRAM}, io.EOF},
30 {100, errClosing, &netFD{sotype: syscall.SOCK_DGRAM}, errClosing},
31 {0, nil, &netFD{sotype: syscall.SOCK_DGRAM}, nil},
32 {0, io.EOF, &netFD{sotype: syscall.SOCK_DGRAM}, io.EOF},
33 {0, errClosing, &netFD{sotype: syscall.SOCK_DGRAM}, errClosing},
35 {100, nil, &netFD{sotype: syscall.SOCK_SEQPACKET}, nil},
36 {100, io.EOF, &netFD{sotype: syscall.SOCK_SEQPACKET}, io.EOF},
37 {100, errClosing, &netFD{sotype: syscall.SOCK_SEQPACKET}, errClosing},
38 {0, nil, &netFD{sotype: syscall.SOCK_SEQPACKET}, io.EOF},
39 {0, io.EOF, &netFD{sotype: syscall.SOCK_SEQPACKET}, io.EOF},
40 {0, errClosing, &netFD{sotype: syscall.SOCK_SEQPACKET}, errClosing},
42 {100, nil, &netFD{sotype: syscall.SOCK_RAW}, nil},
43 {100, io.EOF, &netFD{sotype: syscall.SOCK_RAW}, io.EOF},
44 {100, errClosing, &netFD{sotype: syscall.SOCK_RAW}, errClosing},
45 {0, nil, &netFD{sotype: syscall.SOCK_RAW}, nil},
46 {0, io.EOF, &netFD{sotype: syscall.SOCK_RAW}, io.EOF},
47 {0, errClosing, &netFD{sotype: syscall.SOCK_RAW}, errClosing},
50 func TestEOFError(t *testing.T) {
51 for _, tt := range eofErrorTests {
52 actual := tt.fd.eofError(tt.n, tt.err)
53 if actual != tt.expected {
54 t.Errorf("eofError(%v, %v, %v): expected %v, actual %v", tt.n, tt.err, tt.fd.sotype, tt.expected, actual)