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