git.iko.soy/typeable/postgresql-simple
on master help sign in
Minor cleanups relating to #149

I did investigate using QuickCheck to generate round-trip test cases, but I ran into minor issues regarding integrating the two testing libraries into a single test suite. And honestly, as-is, the test cases as-is are probably a reasonably complete test of the new Generic instances for FromField and ToField. In all likelihood, the logic that QuickCheck-generated roundtrips would really exercise is the FromField and ToField instances. (Which admittedly, is a major hole in the current test suite.)

commit7859acd2a8adf70f28577d6fa6ef61e8c4040330 authorLeon P Smith <leon@melding-monads.com> dateMon 19 Oct 2015, 16:18 (11 years ago) parent4ec19df
1 file changed+15−9
test/Main.hs+15−9
test/Main.hs+15−9
@@ -327,21 +327,27 @@ testDouble TestEnv{..} = TestCase $ do
327327
328328testGeneric1 :: TestEnv -> Test
329329testGeneric1 TestEnv{..} = TestCase $ do
330− let x0 = Gen1 123
331− r <- query conn "SELECT ?::int" x0
332− r @?= [x0]
330+ roundTrip (Gen1 123)
331+ where
332+ roundTrip conn x0 = do
333+ r <- query conn "SELECT ?::int" (x0 :: Gen1)
334+ r @?= [x0]
333335
334336testGeneric2 :: TestEnv -> Test
335337testGeneric2 TestEnv{..} = TestCase $ do
336− let x0 = Gen2 123 "asdf"
337− r <- query conn "SELECT ?::int, ?::text" x0
338− r @?= [x0]
338+ roundTrip conn (Gen2 123 "asdf")
339+ where
340+ roundTrip conn x0 = do
341+ r <- query conn "SELECT ?::int, ?::text" x0
342+ r @?= [x0]
339343
340344testGeneric3 :: TestEnv -> Test
341345testGeneric3 TestEnv{..} = TestCase $ do
342− let x0 = Gen3 123 "asdf" True
343− r <- query conn "SELECT ?::int, ?::text, ?::bool" x0
344− r @?= [x0]
346+ roundTrip conn (Gen3 123 "asdf" True)
347+ where
348+ roundTrip conn x0 = do
349+ r <- query conn "SELECT ?::int, ?::text, ?::bool" x0
350+ r @?= [x0]
345351
346352data Gen1 = Gen1 Int
347353 deriving (Show,Eq,Generic)