2021-06-26 03:17:49 +02: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 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)
|