summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-09-09 18:47:22 +0800
committerGitHub <noreply@github.com>2020-09-09 12:47:22 +0200
commit8c82144ba507244084836b38689e4925de982626 (patch)
treea1f6839815344f6f5073ccda33ad4bc7155f18b9 /tests
parent7d4f0df107fdce5d1da93e26e54dd87526a0a74f (diff)
downloadNim-8c82144ba507244084836b38689e4925de982626.tar.gz
add getprotobyname (#15273)
* add getprotobyname

* tests, docs, changelog

* add since
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/tgetprotobyname.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/stdlib/tgetprotobyname.nim b/tests/stdlib/tgetprotobyname.nim
new file mode 100644
index 000000000..c3d8da0d8
--- /dev/null
+++ b/tests/stdlib/tgetprotobyname.nim
@@ -0,0 +1,25 @@
+discard """
+  cmd:      "nim c -r --styleCheck:hint --panics:on $options $file"
+  targets:  "c"
+  nimout:   ""
+  action:   "run"
+  exitcode: 0
+  timeout:  60.0
+"""
+
+import nativesockets
+
+
+doAssert getProtoByName("ip") == 0
+doAssert getProtoByName("ipv6") == 41
+doAssert getProtoByName("tcp") == 6
+doAssert getProtoByName("udp") == 17
+doAssert getProtoByName("icmp") == 1
+doAssert getProtoByName("ipv6-icmp") == 58
+
+when defined(windows):
+  doAssertRaises(OSError):
+    discard getProtoByName("raw")
+
+doAssertRaises(OSError):
+  discard getProtoByName("Error")