parent
792e4a0392
commit
e718a4a058
3 changed files with 57 additions and 77 deletions
|
|
@ -1,8 +1,4 @@
|
|||
discard """
|
||||
output: "works"
|
||||
"""
|
||||
|
||||
import cgi, strtabs
|
||||
import std/[cgi, strtabs]
|
||||
|
||||
proc handleRequest(query: string): StringTableRef =
|
||||
iterator foo(): StringTableRef {.closure.} =
|
||||
|
|
@ -26,4 +22,3 @@ proc main =
|
|||
quit "but now a leak"
|
||||
|
||||
main()
|
||||
echo "works"
|
||||
|
|
|
|||
|
|
@ -1,25 +1,10 @@
|
|||
discard """
|
||||
output: '''
|
||||
import std/unittest
|
||||
import std/[cgi, strtabs, sugar]
|
||||
|
||||
[Suite] Test cgi module
|
||||
(key: "a", value: "1")
|
||||
(key: "b", value: "0")
|
||||
(key: "c", value: "3")
|
||||
(key: "d", value: "")
|
||||
(key: "e", value: "")
|
||||
(key: "a", value: "5")
|
||||
(key: "a", value: "t e x t")
|
||||
(key: "e", value: "http://w3schools.com/my test.asp?name=ståle&car=saab")
|
||||
'''
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import cgi, strtabs
|
||||
|
||||
suite "Test cgi module":
|
||||
block: # Test cgi module
|
||||
const queryString = "foo=bar&фу=бар&checked=✓&list=1,2,3&with_space=text%20with%20space"
|
||||
|
||||
test "test query parsing with readData":
|
||||
block: # test query parsing with readData
|
||||
let parsedQuery = readData(queryString)
|
||||
|
||||
check parsedQuery["foo"] == "bar"
|
||||
|
|
@ -34,5 +19,8 @@ suite "Test cgi module":
|
|||
# bug #15369
|
||||
let queryString = "a=1&b=0&c=3&d&e&a=5&a=t%20e%20x%20t&e=http%3A%2F%2Fw3schools.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab"
|
||||
|
||||
for pair in decodeData(queryString):
|
||||
echo pair
|
||||
doAssert collect(for pair in decodeData(queryString): pair) ==
|
||||
@[("a", "1"), ("b", "0"), ("c", "3"),
|
||||
("d", ""),("e", ""), ("a", "5"), ("a", "t e x t"),
|
||||
("e", "http://w3schools.com/my test.asp?name=ståle&car=saab")
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue