Module:Monthly Challenge utils/testcases
Appearance
This is the test cases page for the module Module:Monthly Challenge utils. Results of the test cases. |
local MCU = require('Module:Monthly Challenge utils')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
--------------------------------------------------------------------------------
-- Basic tests
--------------------------------------------------------------------------------
-- test the getNextMonth functions
function suite:test_getNextMonth()
local y, m = MCU.getNextMonth(2021, 4, 1)
self:assertEquals(y, 2021)
self:assertEquals(m, 5)
-- test rollover
y, m = MCU.getNextMonth(2021, 12, 1)
self:assertEquals(y, 2022)
self:assertEquals(m, 1)
-- != 1
y, m = MCU.getNextMonth(2021, 11, 3)
self:assertEquals(y, 2022)
self:assertEquals(m, 2)
end
function suite:test_getPrevMonth()
local y, m = MCU.getNextMonth(2021, 4, -1)
self:assertEquals(y, 2021)
self:assertEquals(m, 3)
-- test rollunder
y, m = MCU.getNextMonth(2021, 1, -1)
self:assertEquals(y, 2020)
self:assertEquals(m, 12)
end
return suite