summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-12-27 12:46:21 -0600
committerGitHub <noreply@github.com>2020-12-27 19:46:21 +0100
commite718a4a058f9a9d0c9c8ce1d388040de7c14271d (patch)
tree03176e3dd81a4c9d246ec51f2f784f28edc9cce7 /tests
parent792e4a0392519c7921a0afedb029d02b5485ca64 (diff)
downloadNim-e718a4a058f9a9d0c9c8ce1d388040de7c14271d.tar.gz
follow #15860 clean cgi module (#16487)
* follow #15860  clean cgi module

* follow #15860  clean cgi module
Diffstat (limited to 'tests')
-rw-r--r--tests/gc/growobjcrash.nim7
-rw-r--r--tests/stdlib/tcgi.nim30
2 files changed, 10 insertions, 27 deletions
diff --git a/tests/gc/growobjcrash.nim b/tests/gc/growobjcrash.nim
index 84fd30a4f..ff1aa7e98 100644
--- a/tests/gc/growobjcrash.nim
+++ b/tests/gc/growobjcrash.nim
@@ -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"
diff --git a/tests/stdlib/tcgi.nim b/tests/stdlib/tcgi.nim
index cec188e35..993728712 100644
--- a/tests/stdlib/tcgi.nim
+++ b/tests/stdlib/tcgi.nim
@@ -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")

+]