1module Test.Clock.Conversion 2 ( testClockConversion 3 ) where 4 5import Data.Time.Clock.Compat 6import Data.Time.Clock.System.Compat 7import Test.Tasty 8import Test.Tasty.HUnit 9 10testClockConversion :: TestTree 11testClockConversion = 12 testGroup "clock conversion" $ let 13 testPair :: (SystemTime, UTCTime) -> TestTree 14 testPair (st, ut) = 15 testGroup (show ut) $ 16 [ testCase "systemToUTCTime" $ assertEqual (show ut) ut $ systemToUTCTime st 17 , testCase "utcToSystemTime" $ assertEqual (show ut) st $ utcToSystemTime ut 18 ] 19 in [ testPair (MkSystemTime 0 0, UTCTime systemEpochDay 0) 20 , testPair (MkSystemTime 86399 0, UTCTime systemEpochDay 86399) 21 , testPair (MkSystemTime 86399 999999999, UTCTime systemEpochDay 86399.999999999) 22 , testPair (MkSystemTime 86399 1000000000, UTCTime systemEpochDay 86400) 23 , testPair (MkSystemTime 86399 1999999999, UTCTime systemEpochDay 86400.999999999) 24 , testPair (MkSystemTime 86400 0, UTCTime (succ systemEpochDay) 0) 25 ] 26