1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE ScopedTypeVariables #-}
5 import Data.Function (($), (.))
6 import qualified Data.List as List
7 import Data.Maybe (Maybe(..), fromJust)
8 import Data.Monoid ((<>))
9 import Data.Ord (Ordering(..))
10 import Prelude (Integer)
13 import Test.Tasty.HUnit
14 import Text.Show (Show(..))
16 import qualified Data.Interval as Interval
17 import qualified Sieve.Test as Sieve
23 [ testGroup "position" $
26 let i = fromJust mi in
27 let j = fromJust mj in
30 Interval.Equal -> (EQ, EQ)
32 [ testCase ((show . Interval.Pretty) i <> " " <> (show . Interval.Pretty) j) $
33 Interval.position i j @?= (p, le)
34 , testCase ((show . Interval.Pretty) j <> " " <> (show . Interval.Pretty) i) $
35 Interval.position j i @?= (p, ge)
38 [ ( (Interval.<..<) 0 (4::Integer)
41 , ( (Interval.<..<) 0 4
42 , (Interval.<=..<) 4 9
44 , ( (Interval.<..<) 0 5
47 , ( (Interval.<..<) 0 5
50 , ( (Interval.<..<) 0 9
53 , ( (Interval.<..<) 0 9
56 , ( (Interval.<..<) 0 9
59 , ( (Interval.<..<) 0 9
60 , (Interval.<..<=) 0 9
62 , ( (Interval.<=..<) 0 9
65 , ( (Interval.<=..<=) 0 9
69 , testGroup "intersection" $
72 let i = fromJust mi in
73 let j = fromJust mj in
74 [ testCase ((show . Interval.Pretty) i <> " " <> (show . Interval.Pretty) j) $
75 Interval.intersection i j @?= e
76 , testCase ((show . Interval.Pretty) j <> " " <> (show . Interval.Pretty) i) $
77 Interval.intersection j i @?= e
80 [ ( (Interval.<..<) 0 (4::Integer)
83 , ( (Interval.<..<=) 0 5
84 , (Interval.<=..<) 5 9
85 , (Interval.<=..<=) 5 5 )
86 , ( (Interval.<..<) 0 6
88 , (Interval.<..<) 4 6 )
89 , ( (Interval.<..<=) 0 6
90 , (Interval.<=..<) 4 9
91 , (Interval.<=..<=) 4 6 )
92 , ( (Interval.<..<) 0 6
93 , (Interval.<=..<) 4 9
94 , (Interval.<=..<) 4 6 )
95 , ( (Interval.<..<=) 0 6
97 , (Interval.<..<=) 4 6 )
98 , ( (Interval.<..<) 0 9
100 , (Interval.<..<) 0 9 )
101 , ( (Interval.<=..<) 0 9
102 , (Interval.<..<=) 0 9
103 , (Interval.<..<) 0 9 )
104 , ( (Interval.<..<=) 0 9
105 , (Interval.<=..<) 0 9
106 , (Interval.<..<) 0 9 )
107 , ( (Interval.<=..<=) 0 9
108 , (Interval.<=..<=) 0 9
109 , (Interval.<=..<=) 0 9 )
111 , testGroup "union" $
114 let i = fromJust mi in
115 let j = fromJust mj in
116 [ testCase ((show . Interval.Pretty) i <> " " <> (show . Interval.Pretty) j) $
117 Interval.union i j @?= e
118 , testCase ((show . Interval.Pretty) j <> " " <> (show . Interval.Pretty) i) $
119 Interval.union j i @?= e
122 [ ( (Interval.<..<) 0 (4::Integer)
123 , (Interval.<..<) 5 9
125 , ( (Interval.<..<=) 0 5
126 , (Interval.<..<) 5 9
127 , (Interval.<..<) 0 9 )
128 , ( (Interval.<..<) 0 5
129 , (Interval.<=..<) 5 9
130 , (Interval.<..<) 0 9 )
131 , ( (Interval.<..<=) 0 5
132 , (Interval.<=..<) 5 9
133 , (Interval.<..<) 0 9 )
134 , ( (Interval.<..<) 0 6
135 , (Interval.<..<) 4 9
136 , (Interval.<..<) 0 9 )
137 , ( (Interval.<..<) 0 9
138 , (Interval.<..<) 0 9
139 , (Interval.<..<) 0 9 )
140 , ( (Interval.<=..<) 0 9
141 , (Interval.<..<=) 0 9
142 , (Interval.<=..<=) 0 9 )
143 , ( (Interval.<..<=) 0 9
144 , (Interval.<=..<) 0 9
145 , (Interval.<=..<=) 0 9 )
146 , ( (Interval.<=..<=) 0 9
147 , (Interval.<=..<=) 0 9
148 , (Interval.<=..<=) 0 9 )