Difference between revisions of "Module:User:DePiep/sandbox/testcases"
Jump to navigation
Jump to search
blackwiki>DePiep |
m (19 revisions imported) |
||
| (9 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
| − | -- Unit | + | -- Unit tests. |
local p = require('Module:UnitTests') | local p = require('Module:UnitTests') | ||
| − | function p: | + | function p:test_basic() |
-- basic | -- basic | ||
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij}}', '000 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij}}', '000') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|||}}', '000 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|||}}', '000') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|||7}}', '001 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|||7}}', '001') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||4|}}', '010 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||4|}}', '010') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||4|7}}', '011 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||4|7}}', '011') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2||}}', '100 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2||}}', '100') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2||7}}', '101 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2||7}}', '101') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|4|}}', '110 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|4|}}', '110') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|4|7}}', '111 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|5|4}}', '111') |
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|7|4}}', '111 err') | ||
| + | end | ||
| + | |||
| + | function p:test_borders() | ||
| + | -- jj over length | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||13}}', '001') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||13|4}}', '011') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|13|}}', '101') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|10|13|4}}', '111') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|8|13|4}}', '111 err') | ||
| + | end | ||
| − | -- | + | function p:test_negatives() |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||- | + | -- j neg |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||- | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||-7}}', '001') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|- | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||-7|3}}', '011') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij| | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|-7|}}', '101') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij| | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|3|-5|4}}', '111') |
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|-7|3}}', '111') | ||
| + | -- i neg | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2||}}', '100') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2|7}}', '101') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2||4}}', '110') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2|5|4}}', '111') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2|7|4}}', '111') | ||
| − | -- | + | -- negative length substr |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|| | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|||-4}}', '010') |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2||7}}', ' | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||7|-4}}', '011') |
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||7|-3}}', '011') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2||-4}}', '110') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||8|-4}}', '011') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|7|-4}}', '111') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|10|7|-4}}', '111') | ||
| + | end | ||
| + | function p:test_blanks() | ||
--blank | --blank | ||
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss||2||7}}', '<blank>') | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss||2||7}}', '<blank>') | ||
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss||2|0|7}}', '<blank>') | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss||2|0|7}}', '<blank>') | ||
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|0 | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|7|0}}', '<blank>') |
end | end | ||
| − | function p: | + | function p:test_index_0() |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox| | + | -- i, j =0 error |
| − | self:preprocess_equals('{{#invoke:User:DePiep/sandbox| | + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|0|7}}', '0 index') |
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|0}}', '0 index') | ||
| + | self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|0|0}}', '0 index') | ||
end | end | ||
return p | return p | ||
Latest revision as of 05:00, 30 September 2020
Documentation for this module may be created at Module:User:DePiep/sandbox/testcases/doc
-- Unit tests.
local p = require('Module:UnitTests')
function p:test_basic()
-- basic
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij}}', '000')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|||}}', '000')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|||7}}', '001')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||4|}}', '010')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||4|7}}', '011')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2||}}', '100')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2||7}}', '101')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|4|}}', '110')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|5|4}}', '111')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|7|4}}', '111 err')
end
function p:test_borders()
-- jj over length
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||13}}', '001')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||13|4}}', '011')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|13|}}', '101')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|10|13|4}}', '111')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|8|13|4}}', '111 err')
end
function p:test_negatives()
-- j neg
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||-7}}', '001')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||-7|3}}', '011')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|-7|}}', '101')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|3|-5|4}}', '111')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|-7|3}}', '111')
-- i neg
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2||}}', '100')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2|7}}', '101')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2||4}}', '110')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2|5|4}}', '111')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|-2|7|4}}', '111')
-- negative length substr
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|||-4}}', '010')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||7|-4}}', '011')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||7|-3}}', '011')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2||-4}}', '110')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij||8|-4}}', '011')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|7|-4}}', '111')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|10|7|-4}}', '111')
end
function p:test_blanks()
--blank
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss||2||7}}', '<blank>')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss||2|0|7}}', '<blank>')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|7|0}}', '<blank>')
end
function p:test_index_0()
-- i, j =0 error
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|0|7}}', '0 index')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|2|0}}', '0 index')
self:preprocess_equals('{{#invoke:User:DePiep/sandbox|ss|abcdefghij|0|0}}', '0 index')
end
return p