请输入您要查询的百科知识:

 

词条 Module:User:Mr. Stradivarius/Check ISO 639-1/testcases
释义 -- Unit tests for Check ISO 639-1. Click talk page to run tests.

local p = require('Module:UnitTests')

local isoModule = require('Module:User:Mr. Stradivarius/Check ISO 639-1') -- the module to be tested

local checkISO = isoModule.main

local ScribuntoUnit = require('Module:ScribuntoUnit')

local suite = ScribuntoUnit:new()

function suite.makeError(input)

return mw.ustring.format('Error: invalid input "%s"; please use an ISO 639-1 code', input)

end

function suite.makeCat(sort)

return mw.ustring.format(, sort)

end

function suite.makeErrorAndCat(input)

return suite.makeError(input) .. suite.makeCat(input)

end

function suite:testCodes()

self:assertEquals('en', checkISO{'en'})

self:assertEquals('en', checkISO{'EN'})

self:assertEquals('en', checkISO{' en '})

self:assertEquals('en', checkISO{' EN '})

self:assertEquals('en', checkISO{'en', nocat='true'})

self:assertEquals('en', checkISO{'en', nocat='yes'})

self:assertEquals('en', checkISO{'en', nocat='y'})

self:assertEquals('en', checkISO{'en', nocat='1'})

self:assertEquals('en', checkISO{'en', nocat=' yes '})

self:assertEquals('en', checkISO{'en', nocat=true})

self:assertEquals(suite.makeErrorAndCat('eng'), checkISO{'eng'})

self:assertEquals(suite.makeErrorAndCat('eng'), checkISO{' eng '})

self:assertEquals(suite.makeErrorAndCat('den'), checkISO{'den'})

self:assertEquals(suite.makeErrorAndCat('fiu-vro'), checkISO{'fiu-vro'})

end

function suite:testNames()

self:assertEquals('en', checkISO{'English'})

self:assertEquals('fr', checkISO{'French'})

self:assertEquals('ja', checkISO{'Japanese'})

self:assertEquals(suite.makeErrorAndCat('Anglais'), checkISO{'Anglais'})

self:assertEquals(suite.makeErrorAndCat('Deutsch'), checkISO{'Deutsch'})

self:assertEquals(suite.makeErrorAndCat('Foobar'), checkISO{'Foobar'})

self:assertEquals(suite.makeError('Foobar'), checkISO{'Foobar', nocat = 'true'})

self:assertEquals(suite.makeError('Foobar'), checkISO{'Foobar', nocat = 'yes'})

self:assertEquals(suite.makeError('Foobar'), checkISO{'Foobar', nocat = 'y'})

self:assertEquals(suite.makeError('Foobar'), checkISO{'Foobar', nocat = '1'})

self:assertEquals(suite.makeError('Foobar'), checkISO{'Foobar', nocat = ' yes '})

self:assertEquals(suite.makeError('Foobar'), checkISO{'Foobar', nocat = true})

self:assertEquals(suite.makeErrorAndCat('Foobar'), checkISO{'Foobar', nocat = false})

self:assertEquals(suite.makeErrorAndCat('Foobar'), checkISO{'Foobar', nocat = 'no'})

self:assertEquals(suite.makeErrorAndCat('Foobar'), checkISO{'Foobar', nocat = 'foo'})

end

function suite:testBlank()

self:assertEquals(, checkISO{})

self:assertEquals(, checkISO{' '})

self:assertEquals(, checkISO{{}})

self:assertEquals(, checkISO{true})

self:assertEquals(, checkISO{nil})

end

return suite

1 : Pages with invalid ISO 639-1 language codes

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/12 15:42:01