move tests to testament (#16101)

* move tests to testament

* minor

* fix random

* disable test random
This commit is contained in:
flywind 2020-11-25 02:06:41 +08:00 • committed by GitHub
commit cbc793b30b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 2205 additions and 2232 deletions

View file

@ -345,28 +345,3 @@ func is5xx*(code: HttpCode): bool {.inline.} =
func `$`*(httpMethod: HttpMethod): string =
return (system.`$`(httpMethod))[4 .. ^1].toUpperAscii()
when isMainModule:
var test = newHttpHeaders()
test["Connection"] = @["Upgrade", "Close"]
doAssert test["Connection", 0] == "Upgrade"
doAssert test["Connection", 1] == "Close"
test.add("Connection", "Test")
doAssert test["Connection", 2] == "Test"
doAssert "upgrade" in test["Connection"]
# Bug #5344.
doAssert parseHeader("foobar: ") == ("foobar", @[""])
let (key, value) = parseHeader("foobar: ")
test = newHttpHeaders()
test[key] = value
doAssert test["foobar"] == ""
doAssert parseHeader("foobar:") == ("foobar", @[""])
block: # test title case
var testTitleCase = newHttpHeaders(titleCase=true)
testTitleCase.add("content-length", "1")
doAssert testTitleCase.hasKey("Content-Length")
for key, val in testTitleCase:
doAssert key == "Content-Length"