Module:Lang/codes/testcases
Appearance
This is the test cases page for the module Module:Lang/codes. Results of the test cases. |
local p = require("Module:UnitTests")
local get_ietf_parts = require("Module:Lang/sandbox").get_ietf_parts
local prepare
function p:check(code, expected)
self:equals_deep(code, { get_ietf_parts(code) }, prepare(expected))
end
function p:test()
local examples = {
{ "de", { "de" } },
{ "nav", { "nav" } },
{ "1ca", { "1ca" } },
{ "cmn-Latn", { "cmn", "latn" } },
{ "he-hebr", { "he", "hebr" } },
{ "de-ch", { "de", nil, "ch" } },
{ "de-1901", { "de", nil, nil, "1901" } },
{ "ru-petr1708", { "ru", nil, nil, "petr1708" } },
{ "de-petr1708", {"de"} },
{ "ca-valencia", { "ca", nil, nil, "valencia" } },
{ "ru-cyrl-petr1708", {"ru", "cyrl"} },
{ "ru-Cyril", {"ru"} },
--[[
{ "", { "" } },
--]]
}
self:iterate(examples, "check")
end
function prepare(subtag_table)
if not next(subtag_table) then
return subtag_table
end
for i = 1, 4 do
if subtag_table[i] == nil then
subtag_table[i] = ""
end
end
return subtag_table
end
return p