summary refs log tree commit diff stats
path: root/tests/stdlib/thttpcore.nim
blob: 889c734c58913966729db053e965e2de6c748e94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
discard """
output: "[Suite] httpcore"
"""

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