-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.lua
50 lines (43 loc) · 1.46 KB
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package.cpath = package.cpath..";./?.so"
package.path = package.cpath..";./?.lua"
local htmlentities = require("lib.resty.htmlentities")
local decoder, err = htmlentities.new()
if err then
assert(false, "cannot found libhtmlentities.so")
end
function test(input, output)
local s = decoder.decode(input)
assert(s == output, string.format("test failed: %s => %s (%s)", input, output, s))
print(string.format("test success: %s => %s", input, output))
end
test('Christoph Gärtner', "Christoph Gärtner");
test('abcd', 'abcd')
test('test@example.org', '[email protected]')
test('⊇-¹-ß-⊃-²-∑-³', '⊇-¹-ß-⊃-²-∑-³')
test('test@example.org@', '[email protected]@')
test('⊇-¹-ß-⊃-²-∑-³', '⊇-¹-ß-⊃-²-∑-³')
test('⊇-¹-ß-⊃-²-∑-³-&sub8;', '⊇-¹-ß-⊃-²-∑-³-&sub8;')
test('<html> © π " '', '<html> © π " \'')
test('a & b & c', 'a & b & c')
test('<>\'"&', '<>\'"&')
local hex = {
['߀'] = '߀',
['߁'] = '߁',
['߂'] = '߂',
['߃'] = '߃',
['߄'] = '߄',
['߅'] = '߅',
['߆'] = '߆',
['߇'] = '߇',
['߈'] = '߈',
['߉'] = '߉',
['ߊ'] = 'ߊ',
['ߋ'] = 'ߋ',
['ߌ'] = 'ߌ',
['ߍ'] = 'ߍ',
['ߎ'] = 'ߎ',
['ߏ'] = 'ߏ',
}
for k, v in pairs(hex) do
test(v, k)
end