From: daurnimator Date: Fri, 29 Aug 2014 20:02:40 +0000 (-0400) Subject: spec/timetable_spec: more tests X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/6ba1e0b1252c68552bf5aa841a95f63eb04b7050 spec/timetable_spec: more tests --- diff --git a/spec/timetable_spec.lua b/spec/timetable_spec.lua index 0ff42b1..34c0529 100644 --- a/spec/timetable_spec.lua +++ b/spec/timetable_spec.lua @@ -41,6 +41,8 @@ describe ( "Timetable library" , function ( ) assert_same_wday ( 2014 , 1 , 1 ) assert_same_wday ( 2014 , 1 , 6 ) assert_same_wday ( 2016 , 2 , 28 ) + assert_same_wday ( 2016 , 2 , 29 ) + assert_same_wday ( 2016 , 3 , 1 ) end ) local function native_timestamp ( year , month , day ) @@ -57,6 +59,16 @@ describe ( "Timetable library" , function ( ) end end ) + it ( "#normalise handles out of range days in a year" , function ( ) + assert.same ( { timetable.normalise(2013,1,366,0,0,0) } , { 2014,1,1,0,0,0 } ) + assert.same ( { timetable.normalise(2013,1,400,0,0,0) } , { 2014,2,4,0,0,0 } ) + assert.same ( { timetable.normalise(2016,1,400,0,0,0) } , { 2017,2,3,0,0,0 } ) + assert.same ( { timetable.normalise(2015,1,430,0,0,0) } , { 2016,3,5,0,0,0 } ) + assert.same ( { timetable.normalise(2016,1,430,0,0,0) } , { 2017,3,5,0,0,0 } ) + assert.same ( { timetable.normalise(2000,1,10000,0,0,0) } , { 2027,5,18,0,0,0 } ) + assert.same ( { timetable.normalise(2000,1,10000000,0,0,0) } , { 29379,1,25,0,0,0 } ) + end ) + it ( "#normalise handles out of range days in a #month" , function ( ) assert.same ( { timetable.normalise(2013,0,1,0,0,0) } , { 2012,12,1,0,0,0 } ) assert.same ( { timetable.normalise(2013,42,1,0,0,0) } , { 2016,6,1,0,0,0 } )