summaryrefslogtreecommitdiff
path: root/tests/modules/string/test.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modules/string/test.lua')
-rw-r--r--tests/modules/string/test.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/modules/string/test.lua b/tests/modules/string/test.lua
index 09a0f5a3e..3f52dc593 100644
--- a/tests/modules/string/test.lua
+++ b/tests/modules/string/test.lua
@@ -95,3 +95,14 @@ function test_lastof(t)
t:are_equal(("/home/file.txt"):lastof('/home', true), 1)
t:are_equal(("/home/file.txt"):lastof('[/\\]home'), 1)
end
+
+function test_replace(t)
+ t:are_equal(("123xyz456xyz789xyz"):replace("123", "000"), "000xyz456xyz789xyz")
+ t:are_equal(("123xyz456xyz789xyz"):replace("xyz", "000"), "123000456000789000")
+ t:are_equal(("123xyz456xyz789xyz"):replace("123", "000", {plain = true}), "000xyz456xyz789xyz")
+ t:are_equal(("123xyz456xyz789xyz"):replace("xyz", "000", {plain = true}), "123000456000789000")
+ t:are_equal(("123$xyz456xyz789xyz"):replace("123$", "000"), "123$xyz456xyz789xyz")
+ t:are_equal(("123xyz$456xyz$789xyz$"):replace("xyz$", "000"), "123xyz$456xyz$789xyz$")
+ t:are_equal(("123$xyz456xyz789xyz"):replace("123$", "000", {plain = true}), "000xyz456xyz789xyz")
+ t:are_equal(("123xyz$456xyz$789xyz$"):replace("xyz$", "000", {plain = true}), "123000456000789000")
+end