aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_dbuffer_spec.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-06-29 12:51:28 +0100
committerMatthew Wild <mwild1@gmail.com>2020-06-29 12:51:28 +0100
commit67cf276ba2e23710c9ab2abd7e2f7b377aab1070 (patch)
tree39ea1cc4258cbcb5291e08c8998863cb2f9ae5ba /spec/util_dbuffer_spec.lua
parente93be0e96ecfd43425b06f230d3b2efd9ff7fe5e (diff)
downloadprosody-67cf276ba2e23710c9ab2abd7e2f7b377aab1070.tar.gz
prosody-67cf276ba2e23710c9ab2abd7e2f7b377aab1070.zip
util.dbuffer: If no bytes parameter passed to read, return remainder of frontmost chunk
Diffstat (limited to 'spec/util_dbuffer_spec.lua')
-rw-r--r--spec/util_dbuffer_spec.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/util_dbuffer_spec.lua b/spec/util_dbuffer_spec.lua
index 1a0c2992..c4fa22b2 100644
--- a/spec/util_dbuffer_spec.lua
+++ b/spec/util_dbuffer_spec.lua
@@ -21,6 +21,21 @@ describe("util.dbuffer", function ()
end);
end);
+ describe(":read", function ()
+ it("supports optional bytes parameter", function ()
+ -- should return the frontmost chunk
+ local b = dbuffer.new();
+ assert.truthy(b:write("hello"));
+ assert.truthy(b:write(" "));
+ assert.truthy(b:write("world"));
+ assert.equal("h", b:read(1));
+
+ assert.equal("ello", b:read());
+ assert.equal(" ", b:read());
+ assert.equal("world", b:read());
+ end);
+ end);
+
describe(":discard", function ()
local b = dbuffer.new();
it("works", function ()