tgetprotobyname.nim 429 B

1234567891011121314151617181920
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. """
  4. import nativesockets
  5. import std/assertions
  6. doAssert getProtoByName("ipv6") == 41
  7. doAssert getProtoByName("tcp") == 6
  8. doAssert getProtoByName("udp") == 17
  9. doAssert getProtoByName("icmp") == 1
  10. doAssert getProtoByName("ipv6-icmp") == 58
  11. when defined(windows):
  12. doAssertRaises(OSError):
  13. discard getProtoByName("raw")
  14. doAssertRaises(OSError):
  15. discard getProtoByName("Error")