-- Unit tests for . Click talk page to run tests.local p = require('Module:UnitTests')
local isoModule = require('Module:Sandbox/Mr. Stradivarius/Check ISO 639-1') -- the module to be testedlocal checkISO = isoModule.mainlocal 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) self:assertEquals('en', checkISO) self:assertEquals('en', checkISO) self:assertEquals('en', checkISO) self:assertEquals('en', checkISO) self:assertEquals('en', checkISO) self:assertEquals('en', checkISO) self:assertEquals('en', checkISO) self:assertEquals('en', checkISO) self:assertEquals('en', checkISO) self:assertEquals(suite.makeErrorAndCat('eng'), checkISO) self:assertEquals(suite.makeErrorAndCat('eng'), checkISO) self:assertEquals(suite.makeErrorAndCat('den'), checkISO) self:assertEquals(suite.makeErrorAndCat('fiu-vro'), checkISO)end
function suite:testNames self:assertEquals('en', checkISO) self:assertEquals('fr', checkISO) self:assertEquals('ja', checkISO) self:assertEquals(suite.makeErrorAndCat('Anglais'), checkISO) self:assertEquals(suite.makeErrorAndCat('Deutsch'), checkISO) self:assertEquals(suite.makeErrorAndCat('Foobar'), checkISO) self:assertEquals(suite.makeError('Foobar'), checkISO) self:assertEquals(suite.makeError('Foobar'), checkISO) self:assertEquals(suite.makeError('Foobar'), checkISO) self:assertEquals(suite.makeError('Foobar'), checkISO) self:assertEquals(suite.makeError('Foobar'), checkISO) self:assertEquals(suite.makeError('Foobar'), checkISO) self:assertEquals(suite.makeErrorAndCat('Foobar'), checkISO) self:assertEquals(suite.makeErrorAndCat('Foobar'), checkISO) self:assertEquals(suite.makeErrorAndCat('Foobar'), checkISO)end
function suite:testBlank self:assertEquals(, checkISO) self:assertEquals(, checkISO) self:assertEquals(, checkISO) self:assertEquals(, checkISO) self:assertEquals(, checkISO)end
return suite