diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/thttpcore.nim | 28 | ||||
-rw-r--r-- | tests/stdlib/txmltree.nim | 18 |
2 files changed, 44 insertions, 2 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 diff --git a/tests/stdlib/txmltree.nim b/tests/stdlib/txmltree.nim index bfe2dc94a..a849859e3 100644 --- a/tests/stdlib/txmltree.nim +++ b/tests/stdlib/txmltree.nim @@ -1,6 +1,11 @@ discard """ file: "txmltree.nim" - output: "true" + output: '''true +true +true +true +true +''' """ import xmltree, strtabs @@ -9,5 +14,14 @@ var x = <>a(href="nim.de", newText("www.nim-test.de")) echo($x == "<a href=\"nim.de\">www.nim-test.de</a>") +echo(newText("foo").innerText == "foo") +echo(newEntity("bar").innerText == "bar") +echo(newComment("baz").innerText == "") - +let y = newXmlTree("x", [ + newText("foo"), + newXmlTree("y", [ + newText("bar") + ]) +]) +echo(y.innerText == "foobar") |