1{-# LANGUAGE OverloadedStrings #-}
4import Data.ByteString (ByteString)
6import Database.PostgreSQL.Simple
9import qualified Crypto.Hash.MD5 as MD5
10import qualified Data.ByteString as B
11import qualified Data.ByteString.Base16 as Base16
12import qualified Data.Text.Encoding as TE
14testBytea :: Connection -> Test
15testBytea conn = TestList
17 , testStr "\"hello\"" $ map (fromIntegral . fromEnum) ("hello" :: String)
18 , testStr "ascending" [0..255]
19 , testStr "descending" [255,254..0]
20 , testStr "ascending, doubled up" $ doubleUp [0..255]
21 , testStr "descending, doubled up" $ doubleUp [255,254..0]
24 testStr label bytes = TestLabel label $ TestCase $ do
27 [Only h] <- query conn "SELECT md5(?::bytea)" [Binary bs]
28 assertBool "Haskell -> SQL conversion altered the string" $ md5 bs == h
30 [Only (Binary r)] <- query conn "SELECT ?::bytea" [Binary bs]
31 assertBool "SQL -> Haskell conversion altered the string" $ bs == r
33 doubleUp = concatMap (\x -> [x, x])
35md5 :: ByteString -> Text
36md5 = TE.decodeUtf8 . Base16.encode . MD5.hash
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list