Modul:String/tests
Megjelenés
String modul tesztek[mi ez?]
Név | Várt | Tényleges | |
---|---|---|---|
testLen | |||
testSimpletitle | |||
testMatch |
require('strict')
local p = require"Modul:String"
local ScribuntoUnit = require"Modul:ScribuntoUnit"
local suite = ScribuntoUnit:new()
function suite:testLen()
self:assertEquals(4, p.len{args = {'alma'}})
self:assertEquals(4, p.len{args = {'álma'}})
self:assertEquals(0, p.len{args = {s = ''}})
self:assertEquals(0, p.len{args = {}})
end
function suite:testMatch()
self:assertEquals('2015', p.match{args = {s = '2015', pattern = '%d+', nomatch = ''}})
self:assertEquals('2015-03-31', p.match{args = {s = '2015-03-31', pattern = '%d+%-%d+%-%d+', nomatch = ''}})
self:assertEquals('', p.match{args = {s = '2015', pattern = '%d+%-%d+%-%d+', nomatch = ''}})
self:assertEquals('2015', p.match{args = {s = '2015', pattern = '^%d%d%d%d$', nomatch = ''}})
self:assertEquals('', p.match{args = {s = '20150', pattern = '^%d%d%d%d$', nomatch = ''}})
end
function suite:testSimpletitle()
if mw.ustring.sub(mw.title.getCurrentTitle().text, -5) == "tests" then
self:assertEquals("String/tests", p.simpletitle())
else
self:assertEquals("String", p.simpletitle())
end
self:assertEquals("Budapest", p.simpletitle{ "Budapest (egyértelműsítő lap)" })
self:assertResultEquals("Budapest", "{{#invoke:String|simpletitle|Budapest (egyértelműsítő lap)}}")
end
return suite