summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2016-12-01 18:01:04 +0100
committerGitHub <noreply@github.com>2016-12-01 18:01:04 +0100
commitd6ab21eed53df590b25742c06ac4dff908d8b27d (patch)
tree6693286d786b17202be5e009cfcd006ebbebf225 /tests/stdlib
parent0f700d22778d8d24a3a97c2bcac8885d4bd29cfa (diff)
parent74e442f766183237e8edca7bb68dca1da81a7d9f (diff)
downloadNim-d6ab21eed53df590b25742c06ac4dff908d8b27d.tar.gz
Merge pull request #5080 from FedericoCeratto/httpheaders
Add HTTP header deletion, improve tests
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/thttpcore.nim28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/stdlib/thttpcore.nim b/tests/stdlib/thttpcore.nim
new file mode 100644
index 000000000..9f99df93a
--- /dev/null
+++ b/tests/stdlib/thttpcore.nim
@@ -0,0 +1,28 @@
+
+import unittest
+
+import httpcore
+
+suite "httpcore":
+
+  test "HttpCode":
+    assert $Http418 == "418 I'm a teapot"
+    assert Http418.is4xx() == true
+    assert Http418.is2xx() == false
+
+  test "headers":
+    var h = newHttpHeaders()
+    assert h.len == 0
+    h.add("Cookie", "foo")
+    assert h.len == 1
+    assert h.hasKey("cooKIE")
+    assert h["Cookie"] == "foo"
+    assert h["cookie"] == "foo"
+    h["cookie"] = @["bar", "x"]
+    assert h["Cookie"] == "bar"
+    assert h["Cookie", 1] == "x"
+    assert h["Cookie"].contains("BaR") == true
+    assert h["Cookie"].contains("X") == true
+    assert "baR" in h["cookiE"]
+    h.del("coOKie")
+    assert h.len == 0