Minetest-WorldEditAdditions/.tests/strings/str_starts.test.lua

41 lines
946 B
Lua
Raw Normal View History

2021-06-26 01:17:49 +00:00
local polyfill = require("worldeditadditions.utils.strings.polyfill")
describe("str_starts", function()
it("should return true for a single character", function()
assert.are.equal(
2021-12-31 01:34:41 +00:00
true,
polyfill.str_starts("test", "t")
2021-06-26 01:17:49 +00:00
)
end)
it("should return true for a multiple characters", function()
assert.are.equal(
2021-12-31 01:34:41 +00:00
true,
polyfill.str_starts("test", "te")
2021-06-26 01:17:49 +00:00
)
end)
it("should return true for identical strings", function()
assert.are.equal(
2021-12-31 01:34:41 +00:00
true,
polyfill.str_starts("test", "test")
2021-06-26 01:17:49 +00:00
)
end)
it("should return false for a single character ", function()
assert.are.equal(
2021-12-31 01:34:41 +00:00
false,
polyfill.str_starts("test", "y")
2021-06-26 01:17:49 +00:00
)
end)
it("should return false for a character present elsewherer", function()
assert.are.equal(
2021-12-31 01:34:41 +00:00
false,
polyfill.str_starts("test", "e")
2021-06-26 01:17:49 +00:00
)
end)
it("should return false for another substring", function()
assert.are.equal(
2021-12-31 01:34:41 +00:00
false,
polyfill.str_starts("test", "est")
2021-06-26 01:17:49 +00:00
)
end)
end)