Software /
code /
prosody
Comparison
tests/test_util_http.lua @ 7514:ea58c0fe1cd7
test_util_http: wrap individual test blocks in do-end [luacheck]
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sat, 23 Jul 2016 20:12:53 +0800 |
parent | 5776:bd0ff8ae98a8 |
comparison
equal
deleted
inserted
replaced
7513:8a6c7c4b15fb | 7514:ea58c0fe1cd7 |
---|---|
23 assert_equal(formencode({ { name = "one", value = "1"}, { name = "two", value = "2" } }), "one=1&two=2", "Form encoded"); | 23 assert_equal(formencode({ { name = "one", value = "1"}, { name = "two", value = "2" } }), "one=1&two=2", "Form encoded"); |
24 assert_equal(formencode({ { name = "one two", value = "1"}, { name = "two one&", value = "2" } }), "one+two=1&two+one%26=2", "Form encoded"); | 24 assert_equal(formencode({ { name = "one two", value = "1"}, { name = "two one&", value = "2" } }), "one+two=1&two+one%26=2", "Form encoded"); |
25 end | 25 end |
26 | 26 |
27 function formdecode(formdecode) | 27 function formdecode(formdecode) |
28 local t = formdecode("one=1&two=2"); | 28 do |
29 assert_table(t[1]); | 29 local t = formdecode("one=1&two=2"); |
30 assert_equal(t[1].name, "one"); assert_equal(t[1].value, "1"); | 30 assert_table(t[1]); |
31 assert_table(t[2]); | 31 assert_equal(t[1].name, "one"); assert_equal(t[1].value, "1"); |
32 assert_equal(t[2].name, "two"); assert_equal(t[2].value, "2"); | 32 assert_table(t[2]); |
33 assert_equal(t[2].name, "two"); assert_equal(t[2].value, "2"); | |
34 end | |
33 | 35 |
34 local t = formdecode("one+two=1&two+one%26=2"); | 36 do |
35 assert_equal(t[1].name, "one two"); assert_equal(t[1].value, "1"); | 37 local t = formdecode("one+two=1&two+one%26=2"); |
36 assert_equal(t[2].name, "two one&"); assert_equal(t[2].value, "2"); | 38 assert_equal(t[1].name, "one two"); assert_equal(t[1].value, "1"); |
39 assert_equal(t[2].name, "two one&"); assert_equal(t[2].value, "2"); | |
40 end | |
37 end | 41 end |