From dd0274b8c7499ceac91696cfcfb8e0b799bf0f52 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 23 Jun 2020 16:50:26 +0100 Subject: util.ringbuffer: Add test for :discard() --- spec/util_ringbuffer_spec.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'spec/util_ringbuffer_spec.lua') 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) -- cgit v1.2.3