mirror of
https://github.com/bjc/prosody.git
synced 2025-04-06 22:57:38 +03:00
util.format: Move tests to spec/
This commit is contained in:
parent
1438a38845
commit
0c4ad0fdbc
2 changed files with 13 additions and 10 deletions
13
spec/util_format_spec.lua
Normal file
13
spec/util_format_spec.lua
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
local format = require "util.format".format;
|
||||||
|
|
||||||
|
describe("util.format", function()
|
||||||
|
describe("#format()", function()
|
||||||
|
it("should work", function()
|
||||||
|
assert.equal(format("%s", "hello"), "hello");
|
||||||
|
assert.equal(format("%s"), "<nil>");
|
||||||
|
assert.equal(format("%s", true), "true");
|
||||||
|
assert.equal(format("%d", true), "[true]");
|
||||||
|
assert.equal(format("%%", true), "% [true]");
|
||||||
|
end);
|
||||||
|
end);
|
||||||
|
end);
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
local tostring = tostring;
|
local tostring = tostring;
|
||||||
local select = select;
|
local select = select;
|
||||||
local assert = assert;
|
|
||||||
local unpack = unpack;
|
local unpack = unpack;
|
||||||
local type = type;
|
local type = type;
|
||||||
|
|
||||||
|
@ -60,15 +59,6 @@ local function format(formatstring, ...)
|
||||||
return formatstring:format(unpack(args));
|
return formatstring:format(unpack(args));
|
||||||
end
|
end
|
||||||
|
|
||||||
local function test()
|
|
||||||
assert(format("%s", "hello") == "hello");
|
|
||||||
assert(format("%s") == "<nil>");
|
|
||||||
assert(format("%s", true) == "true");
|
|
||||||
assert(format("%d", true) == "[true]");
|
|
||||||
assert(format("%%", true) == "% [true]");
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
format = format;
|
format = format;
|
||||||
test = test;
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue