File: Main.hs

package info (click to toggle)
haskell-vector-binary-instances 0.2.5.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 88 kB
  • sloc: haskell: 145; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 748 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE ScopedTypeVariables #-}

import Test.Tasty
import Test.Tasty.QuickCheck
import Data.Binary
import Data.Vector.Binary
import qualified Data.Vector as V
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Storable as VS

roundTrip :: forall v a. (Eq (v a), Binary (v a), VG.Vector v a)
          => v a -> Property
roundTrip v =
    let v' = decode $ encode v :: v a
    in property $ v' == v

main = defaultMain $ testGroup "Vector Binary instances"
    [ testProperty "Unboxed"  $ roundTrip $ VU.enumFromTo z 100
    , testProperty "Storable" $ roundTrip $ VS.enumFromTo z 100
    , testProperty "Boxed"    $ roundTrip $ V.enumFromTo  z 100
    ]
  where
    z = 0 :: Int