aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-03-17 17:06:05 +0000
committerMatthew Wild <mwild1@gmail.com>2023-03-17 17:06:05 +0000
commit7a6d2e1226185bf2a839df722c05b9308b78cff7 (patch)
treec3ecb8965f4039a959122b6540900007bdd9367d /spec
parentb156f013c4c68996981dc876d5edcf140e33eb00 (diff)
downloadprosody-7a6d2e1226185bf2a839df722c05b9308b78cff7.tar.gz
prosody-7a6d2e1226185bf2a839df722c05b9308b78cff7.zip
util.table: Expand table.move() tests (thanks mutation testing)
Diffstat (limited to 'spec')
-rw-r--r--spec/util_table_spec.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/util_table_spec.lua b/spec/util_table_spec.lua
index a0535c08..574967f3 100644
--- a/spec/util_table_spec.lua
+++ b/spec/util_table_spec.lua
@@ -22,6 +22,37 @@ describe("util.table", function ()
u_table.move(t2, 1, 3, 3, t3);
assert.same({ "apple", "banana", "cat", "donkey", "elephant" }, t3);
end);
+ it("supports overlapping regions", function ()
+ do
+ local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" };
+ u_table.move(t1, 1, 3, 3);
+ assert.same({ "apple", "banana", "apple", "banana", "carrot", "fig", "grapefruit" }, t1);
+ end
+
+ do
+ local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" };
+ u_table.move(t1, 1, 3, 2);
+ assert.same({ "apple", "apple", "banana", "carrot", "endive", "fig", "grapefruit" }, t1);
+ end
+
+ do
+ local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" };
+ u_table.move(t1, 3, 5, 2);
+ assert.same({ "apple", "carrot", "date", "endive", "endive", "fig", "grapefruit" }, t1);
+ end
+
+ do
+ local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" };
+ u_table.move(t1, 3, 5, 6);
+ assert.same({ "apple", "banana", "carrot", "date", "endive", "carrot", "date", "endive" }, t1);
+ end
+
+ do
+ local t1 = { "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" };
+ u_table.move(t1, 3, 1, 3);
+ assert.same({ "apple", "banana", "carrot", "date", "endive", "fig", "grapefruit" }, t1);
+ end
+ end);
end);
end);