@@ -16,6 +16,7 @@ import "unordered-containers" Data.HashSet (HashSet)
1616import qualified "unordered-containers" Data.HashSet as HashSet
1717import Data.HashMap.Strict (HashMap)
1818import qualified Data.HashMap.Strict as HashMap
19+import Data.List.NonEmpty (NonEmpty(..), nonEmpty)
1920import Data.Map (Map)
2021import Data.Monoid (mempty)
2122import Data.Proxy
@@ -32,6 +33,7 @@ import Data.Swagger.Declare
3233import Test.Hspec
3334import Test.Hspec.QuickCheck
3435import Test.QuickCheck
36+import Test.QuickCheck.Instances ()
3537
3638shouldValidate :: (ToJSON a, ToSchema a) => Proxy a -> a -> Bool
3739shouldValidate _ x = validateToJSON x == []
@@ -69,6 +71,7 @@ spec = do
6971 -- prop "(Maybe [Int])" $ shouldValidate (Proxy :: Proxy (Maybe [Int]))
7072 prop "(IntMap String)" $ shouldValidate (Proxy :: Proxy (IntMap String))
7173 prop "(Set Bool)" $ shouldValidate (Proxy :: Proxy (Set Bool))
74+ prop "(NonEmpty Bool)" $ shouldValidate (Proxy :: Proxy (NonEmpty Bool))
7275 prop "(HashSet Bool)" $ shouldValidate (Proxy :: Proxy (HashSet Bool))
7376 prop "(Either Int String)" $ shouldValidate (Proxy :: Proxy (Either Int String))
7477 prop "(Int, String)" $ shouldValidate (Proxy :: Proxy (Int, String))
@@ -228,35 +231,5 @@ invalidButtonImagesToJSON = genericToJSON defaultOptions
228231instance Arbitrary ButtonImages where
229232 arbitrary = ButtonImages <$> arbitrary
230233
231−-- Arbitrary instances for common types
232−
233−instance (Eq k, Hashable k, Arbitrary k, Arbitrary v) => Arbitrary (HashMap k v) where
234− arbitrary = HashMap.fromList <$> arbitrary
235−
236−instance (Eq a, Hashable a, Arbitrary a) => Arbitrary (HashSet a) where
237− arbitrary = HashSet.fromList <$> arbitrary
238−
239−instance Arbitrary T.Text where
240− arbitrary = T.pack <$> arbitrary
241−
242−instance Arbitrary TL.Text where
243− arbitrary = TL.pack <$> arbitrary
244−
245−instance Arbitrary Day where
246− arbitrary = liftA3 fromGregorian (fmap ((+ 1) . abs) arbitrary) arbitrary arbitrary
247−
248−instance Arbitrary LocalTime where
249− arbitrary = LocalTime
250− <$> arbitrary
251− <*> liftA3 TimeOfDay (choose (0, 23)) (choose (0, 59)) (fromInteger <$> choose (0, 60))
252−
253234instance Eq ZonedTime where
254235 ZonedTime t (TimeZone x _ _) == ZonedTime t' (TimeZone y _ _) = t == t' && x == y
255−
256−instance Arbitrary ZonedTime where
257− arbitrary = ZonedTime
258− <$> arbitrary
259− <*> liftA3 TimeZone arbitrary arbitrary (vectorOf 3 (elements ['A'..'Z']))
260−
261−instance Arbitrary UTCTime where
262− arbitrary = UTCTime <$> arbitrary <*> fmap fromInteger (choose (0, 86400))