error_posix_test.go 981 B

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