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