Jump to content

Module:ISOdate/sandbox/testcases2

Wikibooks වෙතින්
local ISOdate = require('Module:ISOdate/sandbox')._ISOdate-- the module to be tested
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()

function suite:test_01_Parse_simple()
	self:assertEquals( ISOdate('1969-07-20 20:17:40','en'), '20 July 1969, 20:17:40')
	self:assertEquals( ISOdate('1969-07-20 20:17'   ,'en'), '20 July 1969, 20:17')
	self:assertEquals( ISOdate('1969-07-20'         ,'en'), '20 July 1969')
	self:assertEquals( ISOdate('1969-07'            ,'en'), 'July 1969')
	self:assertEquals( ISOdate('1969      '         ,'en'), '1969')
end

function suite:test_02_Parse_with_T()
	self:assertEquals( ISOdate('1969-07-20T20:17:40'  ,'en'), '20 July 1969, 20:17:40')
	self:assertEquals( ISOdate('1969-07-20T20:17:40Z' ,'en'), '20 July 1969, 20:17:40')
	self:assertEquals( ISOdate('+1969-07-20 20:17:40Z','en'), '20 July 1969, 20:17:40')
	self:assertEquals( ISOdate('1969-07-20T20:17'     ,'en'), '20 July 1969, 20:17')
	self:assertEquals( ISOdate('+1969-07-20'          ,'en'), '20 July 1969')
	self:assertEquals( ISOdate('+1969-07'             ,'en'), 'July 1969')
	self:assertEquals( ISOdate('+1969      '          ,'en'), '1969')
end

function suite:test_03_Parse_followed_by_text()
	self:assertEquals( ISOdate('1969-07-20 20:17:40(text)','en'), '20 July 1969, 20:17:40(text)')
	self:assertEquals( ISOdate('1969-07-20 20:17 text'    ,'en'), '20 July 1969, 20:17 text')
	self:assertEquals( ISOdate('1969-07-20 more text'     ,'en'), '20 July 1969 more text')
	self:assertEquals( ISOdate('1969-07 text'             ,'en'), 'July 1969 text')
	self:assertEquals( ISOdate('1969 text'                ,'en'), '1969 text')
end

return suite
"https://si.wikibooks.org/w/index.php?title=Module:ISOdate/sandbox/testcases2&oldid=24395" වෙතින් සම්ප්‍රවේශනය කෙරිණි