mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
Result of mutation testing Remaining mutants are mostly relating to the math.type() fallback. Another case being that array[#array+1] == array[#array+2] and thus doesn't matter.
40 lines
1.1 KiB
Lua
40 lines
1.1 KiB
Lua
describe("util.jsonpointer", function()
|
|
local json, jp;
|
|
setup(function()
|
|
json = require "util.json";
|
|
jp = require "util.jsonpointer";
|
|
end)
|
|
describe("resolve()", function()
|
|
local example;
|
|
setup(function()
|
|
example = json.decode([[{
|
|
"foo": ["bar", "baz"],
|
|
"": 0,
|
|
"a/b": 1,
|
|
"c%d": 2,
|
|
"e^f": 3,
|
|
"g|h": 4,
|
|
"i\\j": 5,
|
|
"k\"l": 6,
|
|
" ": 7,
|
|
"m~n": 8
|
|
}]])
|
|
end)
|
|
it("works", function()
|
|
assert.is_nil(jp.resolve("string", "/string"))
|
|
assert.same(example, jp.resolve(example, ""));
|
|
assert.same({ "bar", "baz" }, jp.resolve(example, "/foo"));
|
|
assert.same("bar", jp.resolve(example, "/foo/0"));
|
|
assert.same(nil, jp.resolve(example, "/foo/-"));
|
|
assert.same(0, jp.resolve(example, "/"));
|
|
assert.same(1, jp.resolve(example, "/a~1b"));
|
|
assert.same(2, jp.resolve(example, "/c%d"));
|
|
assert.same(3, jp.resolve(example, "/e^f"));
|
|
assert.same(4, jp.resolve(example, "/g|h"));
|
|
assert.same(5, jp.resolve(example, "/i\\j"));
|
|
assert.same(6, jp.resolve(example, "/k\"l"));
|
|
assert.same(7, jp.resolve(example, "/ "));
|
|
assert.same(8, jp.resolve(example, "/m~0n"));
|
|
end)
|
|
end)
|
|
end)
|