Software /
code /
prosody
Changeset
10949:8b5b35baf370
util.ringbuffer: Add test for :discard()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 23 Jun 2020 16:50:26 +0100 |
parents | 10948:bebb384090b0 |
children | 10952:05d218aae3d1 |
files | spec/util_ringbuffer_spec.lua |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/spec/util_ringbuffer_spec.lua Tue Jun 23 15:17:35 2020 +0200 +++ b/spec/util_ringbuffer_spec.lua Tue Jun 23 16:50:26 2020 +0100 @@ -24,6 +24,17 @@ assert.truthy(b:write("hi")); end); end); + + describe(":discard", function () + local b = rb.new(); + it("works", function () + assert.truthy(b:write("hello world")); + assert.truthy(b:discard(6)); + assert.equal(5, #b); + assert.equal("world", b:read(5)); + end); + end); + describe(":sub", function () -- Helper function to compare buffer:sub() with string:sub() local function test_sub(b, x, y)