Add tests for string.escapepattern

This commit is contained in:
Aleksi Juvani 2017-04-10 14:37:47 +03:00
parent 87e001d4e9
commit c619314a01

View File

@ -70,3 +70,31 @@
function suite.startswith_OnEmptyNeedle()
test.istrue(string.startswith("Abcdef", ""))
end
--
-- string.escapepattern() tests
--
function suite.escapepattern_escapes()
test.isequal("boost_filesystem%-vc140%.1%.61%.0%.0", string.escapepattern("boost_filesystem-vc140.1.61.0.0"))
test.isequal("footage/down/temp/cars_%[100%]_upper/cars_%[100%]_upper%.exr", string.escapepattern("footage/down/temp/cars_[100]_upper/cars_[100]_upper.exr"))
end
function suite.escapepattern_doesntEscape()
local s = '<something foo="bar" />'
test.isequal(s, s:escapepattern())
s = 'lorem ipsum dolor sit amet'
test.isequal(s, s:escapepattern())
s = 'forward/slashes/foo/bar'
test.isequal(s, s:escapepattern())
s = '\\back\\slashes'
test.isequal(s, s:escapepattern())
s = 'new\nlines'
test.isequal(s, s:escapepattern())
end