diff options
author | Matthew Wild <mwild1@gmail.com> | 2020-06-29 12:51:28 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2020-06-29 12:51:28 +0100 |
commit | e39e20f7f7f1a8554032f060b5dcbc6554e10804 (patch) | |
tree | 39ea1cc4258cbcb5291e08c8998863cb2f9ae5ba /spec/util_dbuffer_spec.lua | |
parent | d38b9625a3bdbcc22ced600cb763581e89681902 (diff) | |
download | prosody-e39e20f7f7f1a8554032f060b5dcbc6554e10804.tar.gz prosody-e39e20f7f7f1a8554032f060b5dcbc6554e10804.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.lua | 15 |
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 () |