File: QuickCheck.hs

package info (click to toggle)
haskell-web-routes 0.27.14.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 104 kB
  • sloc: haskell: 414; makefile: 12
file content (16 lines) | stat: -rw-r--r-- 493 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Web.Routes.QuickCheck where

import qualified Data.Text.Encoding as Text
import Web.Routes.PathInfo (PathInfo, toPathInfo, fromPathInfo)

-- | test that a 'PathInfo' instance is valid
--
-- Generates 'Arbitrary' 'url' values and checks that:
--
--    fromPathInfo . toPathInfo == id
--
pathInfoInverse_prop :: (Eq url, PathInfo url) => url -> Bool
pathInfoInverse_prop url =
    case (fromPathInfo $ Text.encodeUtf8 $ toPathInfo url) of
      Right url' -> url == url'
      _ -> False