Sari la conținut

Modul:StringUtils/testcases

De la Wikipedia, enciclopedia liberă

Eroare Lua: expandTemplate: template "module test cases notice" does not exist.

local p = require('Modul:UnitTests')

function p:test_prependIfMissing()
	self:preprocess_equals("{{#invoke:StringUtils|prependIfMissing|Q123|Q}}", "Q123");
	self:preprocess_equals("{{#invoke:StringUtils|prependIfMissing|123|Q}}", "Q123");
end

function p:test_appendIfMissing()
	self:preprocess_equals("{{#invoke:StringUtils|appendIfMissing|aliale|le}}", "aliale");
	self:preprocess_equals("{{#invoke:StringUtils|appendIfMissing|nio|le}}", "niole");
end
function p:test_capitalize()
	self:preprocess_equals("{{#invoke:StringUtils|capitalize|aliale}}", "Aliale");
	self:preprocess_equals("{{#invoke:StringUtils|capitalize|Alio}}", "Alio");
	self:preprocess_equals("{{#invoke:StringUtils|capitalize|ALIO}}", "ALIO");
end
function p:test_removeStart()
	self:preprocess_equals_many("{{#invoke:StringUtils|removeStart|", "}}", {{'noc|cu', 'noc'}, {'minc|mi', 'nc'}, {'min|min', ''}, {'min|mino', 'min'}})
end
function p:test_removeEnd()
	self:preprocess_equals_many("{{#invoke:StringUtils|removeEnd|", "}}", {{'noc|cu', 'noc'}, {'minc|nc', 'mi'}, {'min|min', ''}, {'min|omin', 'min'}})
end
function p:test_startsWith()
	self:preprocess_equals_many("{{#invoke:StringUtils|startsWith|", "}}", {{'noc|no', tostring(true)}, {'noc|noc', tostring(true)}, {'noc|nocu', tostring(false)}, {'noc|mi', tostring(false)}, {'noc|',  tostring(false)}})
end
function p:test_substringBefore()
	self:preprocess_equals("{{#invoke:StringUtils|substringBefore|[[Fișier:Groundzero.jpg]]|]]}}", "[[Fișier:Groundzero.jpg")
end
return p