mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-22 19:45:02 +00:00
str_ends: write tests
This commit is contained in:
parent
08cff1c967
commit
4597edcf1e
2 changed files with 41 additions and 1 deletions
40
.tests/strings/str_ends.test.lua
Normal file
40
.tests/strings/str_ends.test.lua
Normal file
|
@ -0,0 +1,40 @@
|
|||
local polyfill = require("worldeditadditions.utils.strings.polyfill")
|
||||
|
||||
describe("str_ends", function()
|
||||
it("should return true for a single character", function()
|
||||
assert.are.equal(
|
||||
true,
|
||||
polyfill.str_ends("test", "t")
|
||||
)
|
||||
end)
|
||||
it("should return true for a multiple characters", function()
|
||||
assert.are.equal(
|
||||
true,
|
||||
polyfill.str_ends("test", "st")
|
||||
)
|
||||
end)
|
||||
it("should return true for identical strings", function()
|
||||
assert.are.equal(
|
||||
true,
|
||||
polyfill.str_ends("test", "test")
|
||||
)
|
||||
end)
|
||||
it("should return false for a single character ", function()
|
||||
assert.are.equal(
|
||||
false,
|
||||
polyfill.str_ends("test", "y")
|
||||
)
|
||||
end)
|
||||
it("should return false for a character present elsewherer", function()
|
||||
assert.are.equal(
|
||||
false,
|
||||
polyfill.str_ends("test", "e")
|
||||
)
|
||||
end)
|
||||
it("should return false for another substring", function()
|
||||
assert.are.equal(
|
||||
false,
|
||||
polyfill.str_ends("test", "tes")
|
||||
)
|
||||
end)
|
||||
end)
|
|
@ -54,7 +54,7 @@ else
|
|||
str_padend = str_padend,
|
||||
str_padstart = str_padstart,
|
||||
str_starts = str_starts,
|
||||
str_ends = str_starts,
|
||||
str_ends = str_ends,
|
||||
trim = trim
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue