...

Source file src/net/error_posix_test.go

Documentation: net

		 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  }
		36  

View as plain text