diff options
author | Matthew Wild <mwild1@gmail.com> | 2024-11-12 11:25:49 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2024-11-12 11:25:49 +0000 |
commit | c9cc6f4b6740cf55d2e23ccd3e1bb320391ed571 (patch) | |
tree | 7ffcd320a2b72b4868fafedeac50d90a70f1becb /spec/util_queue_spec.lua | |
parent | cc34f41086e939301a1e6b85e7405bcef620ebff (diff) | |
download | prosody-master.tar.gz prosody-master.zip |
util.queue: tests: Add test for :replace() methodHEADorigin/mastermaster
Diffstat (limited to 'spec/util_queue_spec.lua')
-rw-r--r-- | spec/util_queue_spec.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/util_queue_spec.lua b/spec/util_queue_spec.lua index d73f523d..d9e92e3d 100644 --- a/spec/util_queue_spec.lua +++ b/spec/util_queue_spec.lua @@ -137,4 +137,23 @@ describe("util.queue", function() assert.equal(c, 6); end); end); + describe("replace()", function () + it("should work", function () + local q = queue.new(10); + for i = 1, 5 do + q:push(i); + end + q:replace(6); + local c = 0; + for i in q:consume() do + c = c + 1; + if c > 1 then + assert.is_equal(c, i); + elseif c == 1 then + assert.is_equal(6, i); + end + end + assert.is_equal(5, c); + end); + end); end); |