| 1 |
#include <tads.h> |
| 2 |
|
| 3 |
main(args) |
| 4 |
{ |
| 5 |
local n = 1; |
| 6 |
|
| 7 |
local tests = [ |
| 8 |
'this is a test string', |
| 9 |
'another one? yes--really! we\'ll see how it goes...', |
| 10 |
'under_score', |
| 11 |
'!@#$%^&*()+=[]{}\|;\':",./<>?', |
| 12 |
'A-grave \u00C0, A-acute \u00C1, i-umlaut \u00ef, L-stroke \u0141', |
| 13 |
'a-grave \u00E0, a-acute \u00E1, c-cedilla \u00E7, OE \u0152', |
| 14 |
'R-caron \u0158, r-caron \u0159, dje \u0452, 3/8 \u215C', |
| 15 |
'ldquo \u201c, rdquo \u201d' |
| 16 |
]; |
| 17 |
"Two-way tests:\b"; |
| 18 |
for (local i = 1, local len = tests.length() ; i <= len ; ++i, ++n) |
| 19 |
{ |
| 20 |
local o = tests[i]; |
| 21 |
local e = o.urlEncode(); |
| 22 |
local d = e.urlDecode(); |
| 23 |
|
| 24 |
"<<n>>: |
| 25 |
\no = <<o.htmlify()>> |
| 26 |
\ne = <<e.htmlify()>> |
| 27 |
\nd = <<d.htmlify()>> |
| 28 |
\nd == o ? <<d == o ? 'yes' : 'NO!!'>> |
| 29 |
\b"; |
| 30 |
} |
| 31 |
|
| 32 |
"Invalid character decoding tests:\b"; |
| 33 |
local inv = [ |
| 34 |
'%80%81%82%83%84%85', |
| 35 |
'%c3%a0%a0%c5%92%92' |
| 36 |
]; |
| 37 |
for (local i = 1, local len = inv.length() ; i <= len ; ++i, ++n) |
| 38 |
{ |
| 39 |
local o = inv[i]; |
| 40 |
local d = o.urlDecode(); |
| 41 |
|
| 42 |
"<<n>>: |
| 43 |
\no = <<o.htmlify()>> |
| 44 |
\nd = <<d.htmlify()>> |
| 45 |
\b"; |
| 46 |
} |
| 47 |
} |