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

41 lines
951 B
Lua
Raw Normal View History

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