File: DateSpec.hs

package info (click to toggle)
haskell-http-date 0.0.11-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 92 kB
  • sloc: haskell: 349; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,414 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module DateSpec where

import Control.Monad
import Model
import Network.HTTP.Date
import Test.Hspec

----------------------------------------------------------------

spec :: Spec
spec = do
    describe "formatHTTPDate" $ do
        it "behaves like the model" $ 
            forM_ [0,100000..10000000000] $ \epochtime -> do
                let m = model epochtime
                    o = ours epochtime
                    model = utcToDate . epochTimeToUtcTime
                    ours  = formatHTTPDate . epochTimeToHTTPDate
                o `shouldBe` m
    describe "httpDateToUTC" $ do
        it "behaves like the model" $ 
            forM_ [0,100000..10000000000] $ \epochtime -> do
                let m = epochTimeToUtcTime epochtime
                    o = httpDateToUTC $ epochTimeToHTTPDate epochtime
                o `shouldBe` m
    describe "parseHTTPDate" $ do
        it "behaves like the model" $
            forM_ [0,100000..10000000000] $ \epochtime -> do
                let m = epochTimeToHTTPDate epochtime
                    Just o = parseHTTPDate $ formatHTTPDate m
                o `shouldBe` m
    describe "utcToHTTPDate" $ do
        it "behaves like the model" $
            forM_ [0,100000..10000000000] $ \epochtime -> do
                let m = epochTimeToHTTPDate epochtime
                    o = utcToHTTPDate $ epochTimeToUtcTime epochtime
                o `shouldBe` m