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