aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2024-11-12 11:25:49 +0000
committerMatthew Wild <mwild1@gmail.com>2024-11-12 11:25:49 +0000
commitc9cc6f4b6740cf55d2e23ccd3e1bb320391ed571 (patch)
tree7ffcd320a2b72b4868fafedeac50d90a70f1becb
parentcc34f41086e939301a1e6b85e7405bcef620ebff (diff)
downloadprosody-c9cc6f4b6740cf55d2e23ccd3e1bb320391ed571.tar.gz
prosody-c9cc6f4b6740cf55d2e23ccd3e1bb320391ed571.zip
util.queue: tests: Add test for :replace() method
-rw-r--r--spec/util_queue_spec.lua19
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);