-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more basic tests for RGBs and Illuminants
- Loading branch information
Showing
13 changed files
with
284 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
module Graphics.Color.Illuminant.CIE1931Spec (spec) where | ||
|
||
import Graphics.Color.Space.Common | ||
import Graphics.Color.Illuminant.Common | ||
import Graphics.Color.Illuminant.CIE1931 | ||
|
||
spec :: Spec | ||
spec = | ||
describe "Wikipedia" $ do | ||
describe "IlluminantSpec" $ do | ||
illuminantSpec @'A | ||
illuminantSpec @'B | ||
illuminantSpec @'C | ||
illuminantSpec @'D50 | ||
illuminantSpec @'D55 | ||
illuminantSpec @'D60 | ||
illuminantSpec @'D65 | ||
illuminantSpec @'D75 | ||
illuminantSpec @'E | ||
illuminantSpec @'FL1 | ||
illuminantSpec @'FL2 | ||
illuminantSpec @'FL3 | ||
illuminantSpec @'FL4 | ||
illuminantSpec @'FL5 | ||
illuminantSpec @'FL6 | ||
illuminantSpec @'FL7 | ||
illuminantSpec @'FL8 | ||
illuminantSpec @'FL9 | ||
illuminantSpec @'FL10 | ||
illuminantSpec @'FL11 | ||
illuminantSpec @'FL12 | ||
illuminantSpec @'FL3_1 | ||
illuminantSpec @'FL3_2 | ||
illuminantSpec @'FL3_3 | ||
illuminantSpec @'FL3_4 | ||
illuminantSpec @'FL3_5 | ||
illuminantSpec @'FL3_6 | ||
illuminantSpec @'FL3_7 | ||
illuminantSpec @'FL3_8 | ||
illuminantSpec @'FL3_9 | ||
illuminantSpec @'FL3_10 | ||
illuminantSpec @'FL3_11 | ||
illuminantSpec @'FL3_12 | ||
illuminantSpec @'FL3_13 | ||
illuminantSpec @'FL3_14 | ||
illuminantSpec @'FL3_15 | ||
illuminantSpec @'HP1 | ||
illuminantSpec @'HP2 | ||
illuminantSpec @'HP3 | ||
illuminantSpec @'HP4 | ||
illuminantSpec @'HP5 | ||
describe "Derived Classes" $ do | ||
let is = [A .. HP5] | ||
it "Bounded" $ [minBound .. maxBound] `shouldBe` is | ||
it "Enum" $ forM_ is $ \ i -> toEnum (fromEnum i) `shouldBe` i | ||
it "Read . Show" $ forM_ is $ \ i -> read (show i) `shouldBe` i | ||
it "Read . Show" $ read (show is) `shouldBe` (is :: [CIE1931]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
module Graphics.Color.Illuminant.CIE1964Spec (spec) where | ||
|
||
import Graphics.Color.Space.Common | ||
import Graphics.Color.Illuminant.Common | ||
import Graphics.Color.Illuminant.CIE1964 | ||
|
||
spec :: Spec | ||
spec = | ||
describe "Wikipedia" $ do | ||
describe "IlluminantSpec" $ do | ||
illuminantSpec @'A | ||
illuminantSpec @'B | ||
illuminantSpec @'C | ||
illuminantSpec @'D50 | ||
illuminantSpec @'D55 | ||
illuminantSpec @'D60 | ||
illuminantSpec @'D65 | ||
illuminantSpec @'D75 | ||
illuminantSpec @'E | ||
illuminantSpec @'FL1 | ||
illuminantSpec @'FL2 | ||
illuminantSpec @'FL3 | ||
illuminantSpec @'FL4 | ||
illuminantSpec @'FL5 | ||
illuminantSpec @'FL6 | ||
illuminantSpec @'FL7 | ||
illuminantSpec @'FL8 | ||
illuminantSpec @'FL9 | ||
illuminantSpec @'FL10 | ||
illuminantSpec @'FL11 | ||
illuminantSpec @'FL12 | ||
describe "Derived Classes" $ do | ||
let is = [A .. FL12] | ||
it "Bounded" $ [minBound .. maxBound] `shouldBe` is | ||
it "Enum" $ forM_ is $ \ i -> toEnum (fromEnum i) `shouldBe` i | ||
it "Read . Show" $ forM_ is $ \ i -> read (show i) `shouldBe` i | ||
it "Read . Show" $ read (show is) `shouldBe` (is :: [CIE1964]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
module Graphics.Color.Illuminant.Common | ||
( illuminantSpec | ||
) where | ||
|
||
import Data.Proxy | ||
import Graphics.Color.Space | ||
import Graphics.Color.Model.Common | ||
|
||
|
||
colorTemperatureExpectation :: | ||
forall i. Illuminant i | ||
=> Expectation | ||
colorTemperatureExpectation = | ||
round (unCCT (colorTemperature :: CCT i)) `shouldBe` natVal (Proxy :: Proxy (Temperature i)) | ||
|
||
|
||
illuminantSpec :: | ||
forall i. (Illuminant i) | ||
=> Spec | ||
illuminantSpec = | ||
let wp = whitePoint :: WhitePoint i Double | ||
in describe (showsType (Proxy :: Proxy i) "") $ do | ||
it "colorTemperature" $ colorTemperatureExpectation @i | ||
it "tristimulus to chromaticity" $ | ||
fromColorXYZ (whitePointTristimulus :: Color (XYZ i) Double) `epsilonEqColorDouble` | ||
case wp of | ||
WhitePointChromaticity (Chromaticity c) -> c | ||
prop "whitePointXZ" $ forAll arbitraryElevator $ \ vY -> | ||
sum (whitePointXZ vY wp) `epsilonEqDouble` vY / yWhitePoint wp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
module Graphics.Color.Space.RGB.AdobeRGBSpec (spec, arbitraryElevator) where | ||
|
||
import Graphics.Color.Space.Common | ||
import Graphics.Color.Space.RGB.AdobeRGB | ||
|
||
instance (Elevator e, Random e) => Arbitrary (Color AdobeRGB e) where | ||
arbitrary = ColorRGB <$> arbitraryElevator <*> arbitraryElevator <*> arbitraryElevator | ||
|
||
|
||
spec :: Spec | ||
spec = describe "AdobeRGB" $ do | ||
colorModelSpec @AdobeRGB @Word "AdobeRGB" | ||
colorSpaceLenientSpec @AdobeRGB @_ @Float 0.00001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Color/tests/Graphics/Color/Space/RGB/Derived/AdobeRGBSpec.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE KindSignatures #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
module Graphics.Color.Space.RGB.Derived.AdobeRGBSpec (spec) where | ||
|
||
import Graphics.Color.Illuminant.CIE1931 | ||
import Graphics.Color.Space.Common | ||
import Graphics.Color.Space.RGB.Derived.AdobeRGB | ||
|
||
instance (Elevator e, Random e, Illuminant i) => Arbitrary (Color (AdobeRGB (i :: k)) e) where | ||
arbitrary = ColorRGB <$> arbitraryElevator <*> arbitraryElevator <*> arbitraryElevator | ||
|
||
|
||
spec :: Spec | ||
spec = describe "AdobeRGB" $ do | ||
colorModelSpec @(AdobeRGB 'D65) @Word "AdobeRGB" | ||
colorSpaceSpec @(AdobeRGB 'D65) @_ @Float |
Oops, something went wrong.