Software /
code /
prosody
Comparison
spec/util_dbuffer_spec.lua @ 10980:eaee72c7afbd
util.dbuffer: If no bytes parameter passed to read, return remainder of frontmost chunk
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 29 Jun 2020 12:51:28 +0100 |
parent | 10977:29b9b679bdbc |
child | 11028:d7a403060946 |
comparison
equal
deleted
inserted
replaced
10979:5671d51df26c | 10980:eaee72c7afbd |
---|---|
16 end); | 16 end); |
17 describe(":write", function () | 17 describe(":write", function () |
18 local b = dbuffer.new(); | 18 local b = dbuffer.new(); |
19 it("works", function () | 19 it("works", function () |
20 assert.truthy(b:write("hi")); | 20 assert.truthy(b:write("hi")); |
21 end); | |
22 end); | |
23 | |
24 describe(":read", function () | |
25 it("supports optional bytes parameter", function () | |
26 -- should return the frontmost chunk | |
27 local b = dbuffer.new(); | |
28 assert.truthy(b:write("hello")); | |
29 assert.truthy(b:write(" ")); | |
30 assert.truthy(b:write("world")); | |
31 assert.equal("h", b:read(1)); | |
32 | |
33 assert.equal("ello", b:read()); | |
34 assert.equal(" ", b:read()); | |
35 assert.equal("world", b:read()); | |
21 end); | 36 end); |
22 end); | 37 end); |
23 | 38 |
24 describe(":discard", function () | 39 describe(":discard", function () |
25 local b = dbuffer.new(); | 40 local b = dbuffer.new(); |