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 aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
15 var eofErrorTests
= []struct {
21 {100, nil, &FD
{ZeroReadIsEOF
: true}, nil},
22 {100, io
.EOF
, &FD
{ZeroReadIsEOF
: true}, io
.EOF
},
23 {100, ErrNetClosing
, &FD
{ZeroReadIsEOF
: true}, ErrNetClosing
},
24 {0, nil, &FD
{ZeroReadIsEOF
: true}, io
.EOF
},
25 {0, io
.EOF
, &FD
{ZeroReadIsEOF
: true}, io
.EOF
},
26 {0, ErrNetClosing
, &FD
{ZeroReadIsEOF
: true}, ErrNetClosing
},
28 {100, nil, &FD
{ZeroReadIsEOF
: false}, nil},
29 {100, io
.EOF
, &FD
{ZeroReadIsEOF
: false}, io
.EOF
},
30 {100, ErrNetClosing
, &FD
{ZeroReadIsEOF
: false}, ErrNetClosing
},
31 {0, nil, &FD
{ZeroReadIsEOF
: false}, nil},
32 {0, io
.EOF
, &FD
{ZeroReadIsEOF
: false}, io
.EOF
},
33 {0, ErrNetClosing
, &FD
{ZeroReadIsEOF
: false}, ErrNetClosing
},
36 func TestEOFError(t
*testing
.T
) {
37 for _
, tt
:= range eofErrorTests
{
38 actual
:= tt
.fd
.EOFError(tt
.n
, tt
.err
)
39 if actual
!= tt
.expected
{
40 t
.Errorf("eofError(%v, %v, %v): expected %v, actual %v", tt
.n
, tt
.err
, tt
.fd
.ZeroReadIsEOF
, tt
.expected
, actual
)