From a6c0dcf25be88e82d68edd8ae9dba529e31ade0a Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 18 Mar 2020 22:50:02 +0800 Subject: add string.lastof tests --- tests/modules/string/test.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/modules/string/test.lua') diff --git a/tests/modules/string/test.lua b/tests/modules/string/test.lua index 57e00dd7e..09a0f5a3e 100644 --- a/tests/modules/string/test.lua +++ b/tests/modules/string/test.lua @@ -86,3 +86,12 @@ function test_split(t) t:are_equal((""):split('123', {plain = true, limit = 2, strict = true}), {""}) t:are_equal(("123123"):split('123', {plain = true, limit = 2, strict = true}), {"", "123"}) end + +function test_lastof(t) + t:are_equal(("1.2.3.4.5"):lastof('%.'), 8) + t:are_equal(("1.2.3.4.5"):lastof('.', true), 8) + t:are_equal(("/home/file.txt"):lastof('[/\\]'), 6) + t:are_equal(("/home/file.txt"):lastof('/', true), 6) + t:are_equal(("/home/file.txt"):lastof('/home', true), 1) + t:are_equal(("/home/file.txt"):lastof('[/\\]home'), 1) +end -- cgit v1.3.1