packages feed

prizm-0.1.0.3: tests/QC/SRGB.hs

{-# LANGUAGE FlexibleInstances #-}

module QC.SRGB (tests) where

import Test.Framework.Providers.QuickCheck2 (testProperty)
import Test.QuickCheck

import Control.Monad

import Data.Prizm.Color.SRGB as S
import Data.Prizm.Color.CIE as C
import Data.Prizm.Types

instance Arbitrary (RGB Integer) where
    arbitrary = liftM3 RGB (choose (0, 255)) (choose (0, 255)) (choose (0, 255))

rgb2XYZ v = C.toRGB(S.toXYZ v) == v

tests = [
    testProperty "SRGB <-> CIE XYZ" rgb2XYZ
      ]