Module:Bool/testcases

From Fire Emblem Heroes Wiki
Jump to: navigation, search
Template-info.svg Documentation

☑ All tests passed.

Name Expected Actual
☑ testFalse
☑ testNil
☑ testTrue
local toboolean = require 'Module:Bool'.toboolean
local suite = require 'Module:ScribuntoUnit':new()

function suite:testFalse ()
	suite:assertFalse(toboolean('0'))
	suite:assertFalse(toboolean('no'))
	suite:assertFalse(toboolean('No'))
	suite:assertFalse(toboolean('NO'))
	suite:assertFalse(toboolean('false'))
	suite:assertFalse(toboolean('False'))
	suite:assertFalse(toboolean('FALSE'))
	suite:assertFalse(toboolean(' \r\n\t0\r\n\t '))
	suite:assertFalse(toboolean(0))
	suite:assertFalse(toboolean(false))
end

function suite:testTrue ()
	suite:assertTrue(toboolean('1'))
	suite:assertTrue(toboolean('yes'))
	suite:assertTrue(toboolean('Yes'))
	suite:assertTrue(toboolean('YES'))
	suite:assertTrue(toboolean('true'))
	suite:assertTrue(toboolean('True'))
	suite:assertTrue(toboolean('TRUE'))
	suite:assertTrue(toboolean(' \r\n\t1\r\n\t '))
	suite:assertTrue(toboolean(1))
	suite:assertTrue(toboolean(true))
end

function suite:testNil ()
	suite:assertEquals(nil, toboolean())
	suite:assertEquals(nil, toboolean(nil))
	suite:assertEquals(nil, toboolean(''))
	suite:assertEquals(nil, toboolean('2'))
	suite:assertEquals(nil, toboolean('    '))
end

return suite