Module:zh/testcases

local tests = require('Module:UnitTests') local zh = require('Module:zh')

local py_tests = { {"奧巴馬", "àobāmǎ"}, {"^奧巴馬", "^àobāmǎ"}, {"^奧巴馬", "^àobāmǎ"}, {"陳詞", "chéncí"}, {"長安", "cháng&#39;ān"}, {"長安", "cháng&#39;ān"}, {"長安", "cháng&#39;ān"}, {"長安", "cháng&#39;ān"}, {"安安", "ān&#39;ān"}, {"安安", "ān&#39;ān"}, {"第-二", "dì-èr"}, {"第-二", "dì-èr"}, {"第-二", "dì-èr"}, {"第-二", "dì-èr"}, {{"長安","","",{"cháng"},false}, "cháng&#39;ān", "長{cháng}安"}, {{"長安兒","","",nil,true}, "cháng&#39;ānr", "長安兒"}, {"長安 安全", "cháng&#39;ān ānquán"}, {"長安，安全", "cháng&#39;ān，ānquán"}, {"長安, 安全", "cháng&#39;ān, ānquán"}, }

function tests:test_example for _, test in ipairs(py_tests) do		local hanzi, expected = test[1], test[2] if type(hanzi) == "table" then tests:equals(test[3], zh.py(unpack(hanzi)), expected) else tests:equals(hanzi, zh.py(hanzi), expected) end end end

return tests