Mercurial > prosody-hg
diff spec/util_ringbuffer_spec.lua @ 14176:2bcabbeac9b0 13.0
util.ringbuffer: Fix incorrect returned position from :find() for #needle~=1
And add a test for :find()
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 25 May 2026 14:41:06 +0100 |
| parents | f84e0e2faae2 |
| children | 67b68147ed1d |
line wrap: on
line diff
--- a/spec/util_ringbuffer_spec.lua Mon May 25 13:29:28 2026 +0100 +++ b/spec/util_ringbuffer_spec.lua Mon May 25 14:41:06 2026 +0100 @@ -35,6 +35,22 @@ end); end); + describe(":find", function () + local function test_find(b, str, expected) + if expected ~= nil then + assert.equal(expected, b:find(str)); + else + assert.is_nil(b:find(str)); + end + end + + it("works", function () + local b = rb.new(); + assert.truthy(b:write("hello world")); + test_find(b, "world", 7); + end); + end); + describe(":sub", function () -- Helper function to compare buffer:sub() with string:sub() local function test_sub(b, x, y)
