mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
util.table: Expand table.move() tests (thanks mutation testing)
This commit is contained in:
parent
b156f013c4
commit
7a6d2e1226
1 changed files with 31 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue