From 6ba1e0b1252c68552bf5aa841a95f63eb04b7050 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 29 Aug 2014 16:02:40 -0400 Subject: [PATCH 1/1] spec/timetable_spec: more tests --- spec/timetable_spec.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 } ) -- 2.39.5