@@ -8,6 +8,8 @@ import Test.QuickCheck.Monadic
88
99import Data.Scientific as S
1010import Data.Time
11+ import Text.Printf
12+ import Data.List as L
1113import Data.UUID (UUID , fromWords )
1214import Data.String (IsString )
1315import qualified Data.ByteString as B
@@ -118,20 +120,30 @@ testCodecsEncodeDecode = testGroup "Codecs property 'encode . decode = id'"
118120testCodecsEncodePrint :: TestTree
119121testCodecsEncodePrint = testGroup
120122 " Codecs property 'Encoded value Postgres = value in Haskell'"
121- [ mkCodecEncodeTest " uuid " PGT. uuid qBasic PE. uuid show
123+ [ mkCodecEncodeTest " bool " PGT. bool qBasic PE. bool displayBool
122124 , mkCodecEncodeTest " date" PGT. date qBasic PE. date show
123- , mkCodecEncodeTest " timestamp" PGT. timestamp qBasic PE. timestamp show
124- , mkCodecEncodeTest " timestamptz" PGT. timestamptz
125- " SELECT ($1 at time zone 'UTC')||' UTC'" PE. timestamptz show
125+ , mkCodecEncodeTest " float8" PGT. float8
126+ " SELECT trim(to_char($1, '99999999999990.9999999999'))"
127+ PE. float8 (printf " %.10f" )
128+ , mkCodecEncodeTest " int8" PGT. int8 qBasic PE. int8 show
126129 , mkCodecEncodeTest " interval" PGT. interval
127130 " SELECT extract(epoch from $1)||'s'" PE. interval show
128131 , mkCodecEncodeTest " numeric" PGT. numeric qBasic PE. numeric
129132 displayScientific
133+ , mkCodecEncodeTest " timestamp" PGT. timestamp qBasic PE. timestamp show
134+ , mkCodecEncodeTest " timestamptz" PGT. timestamptz
135+ " SELECT ($1 at time zone 'UTC')||' UTC'" PE. timestamptz show
136+ , mkCodecEncodeTest " uuid" PGT. uuid qBasic PE. uuid show
130137 ]
131138 where
132139 qBasic = " SELECT $1"
140+
133141 displayScientific s | isInteger s = show $ ceiling s
134142 | otherwise = formatScientific S. Fixed Nothing s
143+
144+ displayBool False = " f"
145+ displayBool True = " t"
146+
135147--
136148-- Orphan instances
137149--
0 commit comments