1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
module Test.AddDays where
import Data.Time.Calendar
import Test.TestUtil
import Test.AddDaysRef
days ::[Day]
days =
[
fromGregorian 2005 2 28,
fromGregorian 2004 2 29,
fromGregorian 2004 1 31,
fromGregorian 2004 12 31,
fromGregorian 2005 7 1,
fromGregorian 2005 4 21,
fromGregorian 2005 6 30
]
increments :: [Integer]
increments = [-10,-4,-1,0,1,7,83]
adders :: [(String,Integer -> Day -> Day)]
adders =
[
("day",addDays),
("month (clip)",addGregorianMonthsClip),
("month (roll over)",addGregorianMonthsRollOver),
("year (clip)",addGregorianYearsClip),
("year (roll over)",addGregorianYearsRollOver)
]
resultDays :: [String]
resultDays = do
(aname,adder) <- adders
increment <- increments
day <- days
return ((showGregorian day) ++ " + " ++ (show increment) ++ " * " ++ aname ++ " = " ++ showGregorian (adder increment day))
addDaysTest :: Test
addDaysTest = pureTest "addDays" $
diff addDaysRef $ unlines resultDays
|