-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eca1e9
commit 204bf6d
Showing
7 changed files
with
179 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
htmlEntities = require('src/htmlEntities') | ||
|
||
print('\n\nInit test htmlEntities') | ||
local text = [[&XAMPLE text | ||
⁢≡≡≡≡≡≡≡≡≡≡>]] | ||
|
||
for k,v in pairs(htmlEntities) do | ||
if v and type(v) == 'string' then -- Print Info | ||
print(k .. ': ' .. v) | ||
end | ||
end | ||
|
||
local dec = htmlEntities.decode(text) | ||
print('\nInput: ' .. text .. '\n\nOutput: ' .. dec) | ||
|
||
|
||
repeat | ||
io.write('\nYou want to do a test (y/n) ') | ||
io.flush() | ||
res = io.read() | ||
until res == 'y' or res == 'n' | ||
|
||
function type() | ||
repeat | ||
io.write('\n d = Decode e = Encode s = SpeedTest a = ASCII_Decode\n > ') | ||
io.flush() | ||
res = io.read() | ||
until res == 'd' or res == 'e' or res == 's' or res == 'a' | ||
|
||
function test_decode() | ||
local init = true | ||
while init do | ||
print('\nPut text') | ||
io.write('> ') | ||
input = io.read() | ||
print('Input: ' .. input .. '\nOutput: ' .. htmlEntities.decode(input) .. '\n') | ||
end | ||
end | ||
|
||
function test_encode() | ||
local init = true | ||
while init do | ||
print('\nPut text') | ||
io.write('> ') | ||
input = io.read() | ||
print('Input: '.. input .. '\nOutput: ' .. htmlEntities.encode(input) .. '\n') | ||
end | ||
end | ||
|
||
function test_speed() | ||
print('\n\nInit Time') | ||
local time_init = io.popen('date +%S.%N'):read('*all') | ||
|
||
print('ASCII Decode [HEX 33-255 to DEC] to Char') | ||
local char = {} | ||
for i = 33, 255 do | ||
hex = i | ||
dec = string.format('%02X', hex) | ||
local x_1 = htmlEntities.ASCII_HEX(hex) | ||
table.insert(char, x_1) | ||
local x_2 = htmlEntities.ASCII_DEC(dec) | ||
table.insert(char, x_2) | ||
end | ||
local time_1 = io.popen('date +%S.%N'):read('*all') | ||
|
||
print('Char to encode htmlEntities') | ||
local encode = {'µ', '¥', 'ü', '‎', '™', '⌈', '-'} | ||
for i,v in ipairs(char) do | ||
local x = htmlEntities.encode(v) | ||
table.insert(encode, x) | ||
end | ||
local time_2 = io.popen('date +%S.%N'):read('*all') | ||
|
||
print('decode htmlEntities to Char') | ||
for i,v in ipairs(encode) do | ||
htmlEntities.decode(v) | ||
end | ||
local time_3 = io.popen('date +%S.%N'):read('*all') | ||
|
||
local time = (((time_1 + time_2 + time_3) / 3) - time_init) | ||
print('TIME (%S.%N):' .. time .. '\n\n') | ||
end | ||
|
||
function test_ascii() | ||
print('\nInit Table') | ||
local dec = '' | ||
local hex = '' | ||
for i = 33, 255 do | ||
hex = i | ||
dec = string.format('%02X', hex) | ||
|
||
if string.len(hex) == 3 then | ||
print('HEX: ' .. hex .. ' Output: ' .. htmlEntities.ASCII_HEX(hex)) | ||
else | ||
print('HEX: ' .. hex .. ' Output: ' .. htmlEntities.ASCII_HEX(hex)) | ||
end | ||
|
||
if string.len(dec) == 3 then | ||
print('DEC: ' .. dec .. ' Output: ' .. htmlEntities.ASCII_DEC(dec) .. '\n') | ||
else | ||
print('DEC: ' .. dec .. ' Output: ' .. htmlEntities.ASCII_DEC(dec) .. '\n') | ||
end | ||
|
||
end | ||
end | ||
|
||
-- Res | ||
if res == 'd' then | ||
test_decode() | ||
elseif res == 'e' then | ||
test_encode() | ||
elseif res == 's' then | ||
test_speed() | ||
elseif res == 'a' then | ||
test_ascii() | ||
end | ||
end | ||
|
||
if res == 'y' then type() end |