1module ReadIntSpec (main, spec) where
3import Data.ByteString (ByteString)
5import Network.Wai.Handler.Warp.ReadInt
6import qualified Data.ByteString.Char8 as B
7import qualified Test.QuickCheck as QC
13spec = describe "readInt64" $ do
14 it "converts ByteString to Int" $ QC.property (prop_read_show_idempotent readInt64)
16-- A QuickCheck property. Test that for a number >= 0, converting it to
17-- a string using show and then reading the value back with the function
18-- under test returns the original value.
19-- The functions under test only work on Natural numbers (the Conent-Length
20-- field in a HTTP header is always >= 0) so we check the absolute value of
21-- the value that QuickCheck generates for us.
22prop_read_show_idempotent :: (Integral a, Show a) => (ByteString -> a) -> a -> Bool
23prop_read_show_idempotent freader x = px == freader (toByteString px)
26 toByteString = B.pack . show
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