github.com/sandwichdev/go-internals@v0.0.0-20210605002614-12311ac6b2c5/poll/fd_posix_test.go (about) 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. 4 5 // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows 6 7 package poll_test 8 9 import ( 10 "io" 11 "testing" 12 13 . "github.com/SandwichDev/go-internals/poll" 14 ) 15 16 var eofErrorTests = []struct { 17 n int 18 err error 19 fd *FD 20 expected error 21 }{ 22 {100, nil, &FD{ZeroReadIsEOF: true}, nil}, 23 {100, io.EOF, &FD{ZeroReadIsEOF: true}, io.EOF}, 24 {100, ErrNetClosing, &FD{ZeroReadIsEOF: true}, ErrNetClosing}, 25 {0, nil, &FD{ZeroReadIsEOF: true}, io.EOF}, 26 {0, io.EOF, &FD{ZeroReadIsEOF: true}, io.EOF}, 27 {0, ErrNetClosing, &FD{ZeroReadIsEOF: true}, ErrNetClosing}, 28 29 {100, nil, &FD{ZeroReadIsEOF: false}, nil}, 30 {100, io.EOF, &FD{ZeroReadIsEOF: false}, io.EOF}, 31 {100, ErrNetClosing, &FD{ZeroReadIsEOF: false}, ErrNetClosing}, 32 {0, nil, &FD{ZeroReadIsEOF: false}, nil}, 33 {0, io.EOF, &FD{ZeroReadIsEOF: false}, io.EOF}, 34 {0, ErrNetClosing, &FD{ZeroReadIsEOF: false}, ErrNetClosing}, 35 } 36 37 func TestEOFError(t *testing.T) { 38 for _, tt := range eofErrorTests { 39 actual := tt.fd.EOFError(tt.n, tt.err) 40 if actual != tt.expected { 41 t.Errorf("eofError(%v, %v, %v): expected %v, actual %v", tt.n, tt.err, tt.fd.ZeroReadIsEOF, tt.expected, actual) 42 } 43 } 44 }