tcgi.nim 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. discard """
  2. output: '''
  3. [Suite] Test cgi module
  4. (key: "a", value: "1")
  5. (key: "b", value: "0")
  6. (key: "c", value: "3")
  7. (key: "d", value: "")
  8. (key: "e", value: "")
  9. (key: "a", value: "5")
  10. (key: "a", value: "t e x t")
  11. (key: "e", value: "http://w3schools.com/my test.asp?name=ståle&car=saab")
  12. '''
  13. """
  14. import unittest
  15. import cgi, strtabs
  16. suite "Test cgi module":
  17. const queryString = "foo=bar&фу=бар&checked=✓&list=1,2,3&with_space=text%20with%20space"
  18. test "test query parsing with readData":
  19. let parsedQuery = readData(queryString)
  20. check parsedQuery["foo"] == "bar"
  21. check parsedQuery["фу"] == "бар"
  22. check parsedQuery["checked"] == "✓"
  23. check parsedQuery["list"] == "1,2,3"
  24. check parsedQuery["with_space"] == "text with space"
  25. expect KeyError:
  26. discard parsedQuery["not_existing_key"]
  27. # bug #15369
  28. 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"
  29. for pair in decodeData(queryString):
  30. echo pair