aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-06-23 16:50:26 +0100
committerMatthew Wild <mwild1@gmail.com>2020-06-23 16:50:26 +0100
commitdd0274b8c7499ceac91696cfcfb8e0b799bf0f52 (patch)
tree594478fd06063f91e44f4bf7a8a2c651da6cc786 /spec
parent49663eba20340f7564012ebaa52a75e9a3057c10 (diff)
downloadprosody-dd0274b8c7499ceac91696cfcfb8e0b799bf0f52.tar.gz
prosody-dd0274b8c7499ceac91696cfcfb8e0b799bf0f52.zip
util.ringbuffer: Add test for :discard()
Diffstat (limited to 'spec')
-rw-r--r--spec/util_ringbuffer_spec.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/util_ringbuffer_spec.lua b/spec/util_ringbuffer_spec.lua
index 72656899..9a50fd20 100644
--- a/spec/util_ringbuffer_spec.lua
+++ b/spec/util_ringbuffer_spec.lua
@@ -24,6 +24,17 @@ describe("util.ringbuffer", function ()
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)