github.com/gidoBOSSftw5731/go/src@v0.0.0-20210226122457-d24b0edbf019/net/error_posix_test.go (about) 1 // Copyright 2015 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 !plan9 6 // +build !plan9 7 8 package net 9 10 import ( 11 "os" 12 "syscall" 13 "testing" 14 ) 15 16 func TestSpuriousENOTAVAIL(t *testing.T) { 17 for _, tt := range []struct { 18 error 19 ok bool 20 }{ 21 {syscall.EADDRNOTAVAIL, true}, 22 {&os.SyscallError{Syscall: "syscall", Err: syscall.EADDRNOTAVAIL}, true}, 23 {&OpError{Op: "op", Err: syscall.EADDRNOTAVAIL}, true}, 24 {&OpError{Op: "op", Err: &os.SyscallError{Syscall: "syscall", Err: syscall.EADDRNOTAVAIL}}, true}, 25 26 {syscall.EINVAL, false}, 27 {&os.SyscallError{Syscall: "syscall", Err: syscall.EINVAL}, false}, 28 {&OpError{Op: "op", Err: syscall.EINVAL}, false}, 29 {&OpError{Op: "op", Err: &os.SyscallError{Syscall: "syscall", Err: syscall.EINVAL}}, false}, 30 } { 31 if ok := spuriousENOTAVAIL(tt.error); ok != tt.ok { 32 t.Errorf("spuriousENOTAVAIL(%v) = %v; want %v", tt.error, ok, tt.ok) 33 } 34 } 35 }