aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_util_queue.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2017-09-15 17:07:57 -0400
committerWaqas Hussain <waqas20@gmail.com>2017-09-15 17:07:57 -0400
commit67293fc09fea737de37a2fea7b211aa44695b5bf (patch)
treeb5cd2d09f0ee7e1e9e13feec26defe4f7d9f5003 /tests/test_util_queue.lua
parent4c6c255113df008869577d4ec0291ff880b1273c (diff)
downloadprosody-67293fc09fea737de37a2fea7b211aa44695b5bf.tar.gz
prosody-67293fc09fea737de37a2fea7b211aa44695b5bf.zip
Port tests to the `busted` test runner
Diffstat (limited to 'tests/test_util_queue.lua')
-rw-r--r--tests/test_util_queue.lua74
1 files changed, 0 insertions, 74 deletions
diff --git a/tests/test_util_queue.lua b/tests/test_util_queue.lua
deleted file mode 100644
index e215ba33..00000000
--- a/tests/test_util_queue.lua
+++ /dev/null
@@ -1,74 +0,0 @@
-
-function new(new)
- do
- local q = new(10);
-
- assert_equal(q.size, 10);
- assert_equal(q:count(), 0);
-
- assert_is(q:push("one"));
- assert_is(q:push("two"));
- assert_is(q:push("three"));
-
- for i = 4, 10 do
- assert_is(q:push("hello"));
- assert_equal(q:count(), i, "count is not "..i.."("..q:count()..")");
- end
- assert_equal(q:push("hello"), nil, "queue overfull!");
- assert_equal(q:push("hello"), nil, "queue overfull!");
- assert_equal(q:pop(), "one", "queue item incorrect");
- assert_equal(q:pop(), "two", "queue item incorrect");
- assert_is(q:push("hello"));
- assert_is(q:push("hello"));
- assert_equal(q:pop(), "three", "queue item incorrect");
- assert_is(q:push("hello"));
- assert_equal(q:push("hello"), nil, "queue overfull!");
- assert_equal(q:push("hello"), nil, "queue overfull!");
-
- assert_equal(q:count(), 10, "queue count incorrect");
-
- for _ = 1, 10 do
- assert_equal(q:pop(), "hello", "queue item incorrect");
- end
-
- assert_equal(q:count(), 0, "queue count incorrect");
-
- assert_is(q:push(1));
- for i = 1, 1001 do
- assert_equal(q:pop(), i);
- assert_equal(q:count(), 0);
- assert_is(q:push(i+1));
- assert_equal(q:count(), 1);
- end
- assert_equal(q:pop(), 1002);
- assert_is(q:push(1));
- for i = 1, 1000 do
- assert_equal(q:pop(), i);
- assert_is(q:push(i+1));
- end
- assert_equal(q:pop(), 1001);
- assert_equal(q:count(), 0);
- end
-
- do
- -- Test queues that purge old items when pushing to a full queue
- local q = new(10, true);
-
- for i = 1, 10 do
- q:push(i);
- end
-
- assert_equal(q:count(), 10);
-
- assert_is(q:push(11));
- assert_equal(q:count(), 10);
- assert_equal(q:pop(), 2); -- First item should have been purged
-
- for i = 12, 32 do
- assert_is(q:push(i));
- end
-
- assert_equal(q:count(), 10);
- assert_equal(q:pop(), 23);
- end
-end