mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 18:02:05 +00:00
Added cgi.readData. Add test for cgi module. (#9645)
Added cgi.readData. Add test for cgi module.
This commit is contained in:
committed by
Andreas Rumpf
parent
c50a04adc5
commit
3f3aee4078
23
tests/stdlib/tcgi.nim
Normal file
23
tests/stdlib/tcgi.nim
Normal file
@@ -0,0 +1,23 @@
|
||||
discard """
|
||||
action: run
|
||||
file: tcgi.nim
|
||||
output: "[Suite] Test cgi module"
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import cgi, strtabs
|
||||
|
||||
suite "Test cgi module":
|
||||
const queryString = "foo=bar&фу=бар&checked=✓&list=1,2,3&with_space=text%20with%20space"
|
||||
|
||||
test "test query parsing with readData":
|
||||
let parsedQuery = readData(queryString)
|
||||
|
||||
check parsedQuery["foo"] == "bar"
|
||||
check parsedQuery["фу"] == "бар"
|
||||
check parsedQuery["checked"] == "✓"
|
||||
check parsedQuery["list"] == "1,2,3"
|
||||
check parsedQuery["with_space"] == "text with space"
|
||||
|
||||
expect KeyError:
|
||||
discard parsedQuery["not_existing_key"]
|
||||
Reference in New Issue
Block a user