git.iko.soy/typeable/http-api-data
on master help sign in
Add tests for time types
4cfbeb4Nickolay Kudasov
test/Spec.hs+23
@@ -27,6 +27,25 @@ instance Arbitrary L.Text where
27instance Arbitrary Day where
27instance Arbitrary Day where
28 arbitrary = liftA3 fromGregorian (fmap abs arbitrary) arbitrary arbitrary
28 arbitrary = liftA3 fromGregorian (fmap abs arbitrary) arbitrary arbitrary
29
29
30+instance Arbitrary LocalTime where
31+ arbitrary = LocalTime
32+ <$> arbitrary
33+ <*> liftA3 TimeOfDay (choose (0, 23)) (choose (0, 59)) (fromInteger <$> choose (0, 60))
34+
35+instance Eq ZonedTime where
36+ ZonedTime t (TimeZone x _ _) == ZonedTime t' (TimeZone y _ _) = t == t' && x == y
37+
38+instance Arbitrary ZonedTime where
39+ arbitrary = ZonedTime
40+ <$> arbitrary
41+ <*> liftA3 TimeZone arbitrary arbitrary (vectorOf 3 (elements ['A'..'Z']))
42+
43+instance Arbitrary UTCTime where
44+ arbitrary = UTCTime <$> arbitrary <*> fmap fromInteger (choose (0, 86400))
45+
46+instance Arbitrary NominalDiffTime where
47+ arbitrary = fromInteger <$> arbitrary
48+
30instance Arbitrary Version where
49instance Arbitrary Version where
31 arbitrary = (version . map abs) <$> nonempty
50 arbitrary = (version . map abs) <$> nonempty
32 where
51 where
@@ -89,6 +108,10 @@ spec = do
89 checkUrlPiece (Proxy :: Proxy T.Text) "Text.Strict"
108 checkUrlPiece (Proxy :: Proxy T.Text) "Text.Strict"
90 checkUrlPiece (Proxy :: Proxy L.Text) "Text.Lazy"
109 checkUrlPiece (Proxy :: Proxy L.Text) "Text.Lazy"
91 checkUrlPiece (Proxy :: Proxy Day) "Day"
110 checkUrlPiece (Proxy :: Proxy Day) "Day"
111+ checkUrlPiece (Proxy :: Proxy LocalTime) "LocalTime"
112+ checkUrlPiece (Proxy :: Proxy ZonedTime) "ZonedTime"
113+ checkUrlPiece (Proxy :: Proxy UTCTime) "UTCTime"
114+ checkUrlPiece (Proxy :: Proxy NominalDiffTime) "NominalDiffTime"
92 checkUrlPiece (Proxy :: Proxy Version) "Version"
115 checkUrlPiece (Proxy :: Proxy Version) "Version"
93
116
94 checkUrlPiece (Proxy :: Proxy (Maybe String)) "Maybe String"
117 checkUrlPiece (Proxy :: Proxy (Maybe String)) "Maybe String"