--[=[  
Unit tests for Module:Citation/CS1/Date validation.  
Click talk page to run tests.  
]=]  
local p = require('Module:UnitTests')
----------------------------< Y M X _ D A T E S >------------------------------------------------------------  
function p:test_ymx_dates -- EDTF dates
self:preprocess_equals_preprocess_many(
*, *,
{
{'date=1500-10-XX'}, -- invalid year
{'date=5500-10-XX'}, -- invalid year
{'date=1980-00-XX'}, -- invalid month
{'date=1980-13-XX'}, -- invalid month
{'date=2000-02-XX'},
},
{nowiki=false, templatestyles=true}
end  
----------------------------< Y M D _ D A T E S >------------------------------------------------------------  
function p:test_ymd_dates
self:preprocess_equals_preprocess_many(
*, *,
{
{'date=1500-10-23'}, -- invalid year
{'date=5500-10-23'}, -- invalid year
{'date=1980-00-23'}, -- invalid month
{'date=1980-13-23'}, -- invalid month
{'date=1980-10-00'}, -- invalid day
{'date=1980-10-55'}, -- invalid day
{'date=1700-02-29'}, -- invalid date
{'date=2000-02-29'},
},
{nowiki=false, templatestyles=true}
end  
----------------------------< M D Y _ D A T E S >------------------------------------------------------------  
function p:test_mdy_dates
self:preprocess_equals_preprocess_many(
*, *,
{
{'date=October 23, 96'}, -- invalid year
{'date=October 23, 5500'}, -- invalid year
{'date=Oktober 23, 1980'}, -- invalid month
{'date=october 23, 1980'}, -- invalid month
{'date=Sept 23, 1980'}, -- invalid month
{'date=sep 23, 1980'}, -- invalid month
{'date=October 00, 1980'}, -- invalid day
{'date=October 55, 1980'}, -- invalid day
{'date=February 29, 1700'}, -- invalid date
{'date=October 23 1980'}, -- missing comma
{'date=October, 23 1980'}, -- misplaced comma
{'date=October 23,1980'}, -- missing space
{'date=October23, 1980'}, -- missing space
{'date=February 29, 2000'},
{'date=பிப்ரவரி 29, 2000'},
},
{nowiki=false, templatestyles=true}
end  
----------------------------< M D D Y _ D A T E S >----------------------------------------------------------  
function p:test_mddy_dates
self:preprocess_equals_preprocess_many(
*, *,
{
{'date=October 23–25, 96'}, -- invalid year
{'date=October 23–25, 5500'}, -- invalid year
{'date=Oktober 23–25, 1980'}, -- invalid month
{'date=october 23–25, 1980'}, -- invalid month
{'date=Sept 23–25, 1980'}, -- invalid month
{'date=sep 23–25, 1980'}, -- invalid month
{'date=October 00–25, 1980'}, -- invalid day
{'date=October 23–55, 1980'}, -- invalid day
{'date=October 25–23, 1980'}, -- invalid day order
{'date=October 23–23, 1980'}, -- invalid 2nd day
{'date=February 25–29, 1700'}, -- invalid 2nd day
{'date=October 23–25 1980'}, -- missing comma
{'date=October, 23–25 1980'}, -- misplaced comma
{'date=October 23–25,1980'}, -- missing space
{'date=October23–25, 1980'}, -- missing space
{'date=October 23 –25, 1980'}, -- extraneous space
{'date=October 23– 25, 1980'}, -- extraneous space
{'date=October 23-25, 1980'}, -- hyphen
{'date=February 25–29, 2000'},
{'date=பிப்ரவரி 25–29, 2000'},
},
{nowiki=false, templatestyles=true}
end  
----------------------------< D M Y _ D A T E S >------------------------------------------------------------  
function p:test_dmy_dates
self:preprocess_equals_preprocess_many(
*, *,
{
{'date=23 October 96'}, -- invalid year
{'date=23 October 5500'}, -- invalid year
{'date=23 Oktober 1980'}, -- invalid month
{'date=23 october 1980'}, -- invalid month
{'date=23 Sept 1980'}, -- invalid month
{'date=23 sep 1980'}, -- invalid month
{'date=00 October 1980'}, -- invalid day
{'date=55 October 1980'}, -- invalid day
{'date=29 February 1700'}, -- invalid date
{'date=23, October 1980'}, -- extraneous comma
{'date=23 October, 1980'}, -- extraneous comma
{'date=23October 1980'}, -- missing space
{'date=23 October1980'}, -- missing space
{'date=29 February 2000'},
{'date=29 பிப்ரவரி 2000'},
},
{nowiki=false, templatestyles=true}
end  
----------------------------< D D M Y _ D A T E S >----------------------------------------------------------  
function p:test_ddmy_dates
self:preprocess_equals_preprocess_many(
*, *,
{
{'date=23–25 October 96'}, -- invalid year
{'date=23–25 October 5500'}, -- invalid year
{'date=23–25 Oktober 1980'}, -- invalid month
{'date=23–25 october 1980'}, -- invalid month
{'date=23–25 Sept 1980'}, -- invalid month
{'date=23–25 sep 1980'}, -- invalid month
{'date=00–25 October 1980'}, -- invalid day
{'date=23–55 October 1980'}, -- invalid day
{'date=25–23 October 1980'}, -- invalid day order
{'date=23–23 February 1700'}, -- invalid 2nd day
{'date=23–29 February 1700'}, -- invalid 2nd day
{'date=23–25, October 1980'}, -- extraneous comma
{'date=23–25 October, 1980'}, -- extraneous comma
{'date=23–25 October1980'}, -- missing space
{'date=23–25October 1980'}, -- missing space
{'date=23 –25 October 1980'}, -- extraneous space
{'date=23– 25 October 1980'}, -- extraneous space
{'date=23-25 October 1980'}, -- hyphen
{'date=23–25 February 2000'},
{'date=23–25 பிப்ரவரி 2000'},
},
{nowiki=false, templatestyles=true}
end  
----------------------------< M D M D Y _ D A T E S >--------------------------------------------------------  
function p:test_mdmdy_dates
self:preprocess_equals_preprocess_many(
*, *,
{
{'date=October 23 – November 25, 96'}, -- invalid year
{'date=October 23 – November 25, 5500'}, -- invalid year
{'date=Oktober 23 – November 25, 1980'}, -- invalid 1st month
{'date=October 23 – Novembre 25, 1980'}, -- invalid 2nd month
{'date=october 23 – November 25, 1980'}, -- invalid 1st month
{'date=October 23 – november 25, 1980'}, -- invalid 2nd month
{'date=Sept 23 – Oct 25, 1980'}, -- invalid 1st month
{'date=Sep 23 – Okt 25, 1980'}, -- invalid 2nd month
{'date=sep 23 – Oct 25, 1980'}, -- invalid 1st month
{'date=Sep 23 – oct 25, 1980'}, -- invalid 2nd month
{'date=October 25 – October 29, 1980'}, -- invalid 2nd month
{'date=October 00 – November 25, 1980'}, -- invalid 1st day
{'date=October 23 – November 55, 1980'}, -- invalid 2nd day
{'date=October 23 – November 25 1980'}, -- missing comma
{'date=October, 23 – November 25 1980'}, -- misplaced comma
{'date=October 23, – November 25 1980'}, -- misplaced comma
{'date=October 23 – November, 25 1980'}, -- misplaced comma
{'date=October23 – November 25, 1980'}, -- missing space
{'date=October 23– November 25, 1980'}, -- missing space
{'date=October 23 –November 25, 1980'}, -- missing space
{'date=October 23 – November25, 1980'}, -- missing space
{'date=October 23 – November 25,1980'}, -- missing space
{'date=Oct 23 – November 25, 1980'}, -- mixed style
{'date=October 23 – Nov 25, 1980'}, -- mixed style
{'date=October 23 – September 25, 1980'}, -- invalid month order
{'date=Oct 23 – Sep 25, 1980'}, -- invalid month order
{'date=October 23 – October 23, 1980'}, -- same dates
{'date=October 23 - November 25, 1980'}, -- hyphen
{'date=January 25 – February 29, 2000'},
},
{nowiki=false, templatestyles=true}
end  
----------------------------< D M D M Y _ D A T E S >--------------------------------------------------------  
function p:test_dmdmy_dates
self:preprocess_equals_preprocess_many(
*, *,
{
{'date=23 October – 25 November 96'}, -- invalid year
{'date=23 October – 25 November 5500'}, -- invalid year
{'date=23 Oktober – 25 November 1980'}, -- invalid 1st month
{'date=23 October – 25 Novembre 1980'}, -- invalid 2nd month
{'date=23 october – 25 November 1980'}, -- invalid 1st month
{'date=23 October – 25 november 1980'}, -- invalid 2nd month
{'date=23 Sept – 25 Oct 1980'}, -- invalid 1st month
{'date=23 Sep – 25 Okt 1980'}, -- invalid 2nd month
{'date=23 sep – 25 Oct 1980'}, -- invalid 1st month
{'date=23 Sep – 25 oct 1980'}, -- invalid 2nd month
{'date=23 October – 29 October 1980'}, -- invalid 2nd month
{'date=00 October – 25 November 1980'}, -- invalid 1st day
{'date=23 October – 55 November 1980'}, -- invalid 2nd day
{'date=23, October – 25 November 1980'}, -- extraneous comma
{'date=23 October, – 25 November 1980'}, -- extraneous comma
{'date=23 October – 25, November 1980'}, -- extraneous comma