Revision dde8b625
b/test/hs/Test/Ganeti/JSON.hs | ||
---|---|---|
28 | 28 |
|
29 | 29 |
module Test.Ganeti.JSON (testJSON) where |
30 | 30 |
|
31 |
import Control.Monad |
|
31 | 32 |
import Data.List |
32 | 33 |
import Test.QuickCheck |
33 | 34 |
|
... | ... | |
35 | 36 |
|
36 | 37 |
import Test.Ganeti.TestHelper |
37 | 38 |
import Test.Ganeti.TestCommon |
39 |
import Test.Ganeti.Types () |
|
38 | 40 |
|
39 | 41 |
import qualified Ganeti.BasicTypes as BasicTypes |
40 | 42 |
import qualified Ganeti.JSON as JSON |
41 | 43 |
|
44 |
instance Arbitrary JSON.TimeAsDoubleJSON where |
|
45 |
arbitrary = liftM JSON.TimeAsDoubleJSON arbitrary |
|
46 |
|
|
42 | 47 |
prop_toArray :: [Int] -> Property |
43 | 48 |
prop_toArray intarr = |
44 | 49 |
let arr = map J.showJSON intarr in |
... | ... | |
76 | 81 |
, Data.List.isInfixOf k e ==? True |
77 | 82 |
] |
78 | 83 |
|
84 |
prop_TimeAsDoubleJSON_serialisation :: JSON.TimeAsDoubleJSON -> Property |
|
85 |
prop_TimeAsDoubleJSON_serialisation = testSerialisation |
|
86 |
|
|
79 | 87 |
testSuite "JSON" |
80 | 88 |
[ 'prop_toArray |
81 | 89 |
, 'prop_toArrayFail |
82 | 90 |
, 'prop_arrayMaybeFromObj |
83 | 91 |
, 'prop_arrayMaybeFromObjFail |
92 |
, 'prop_TimeAsDoubleJSON_serialisation |
|
84 | 93 |
] |
b/test/hs/Test/Ganeti/Types.hs | ||
---|---|---|
37 | 37 |
, JobId(..) |
38 | 38 |
) where |
39 | 39 |
|
40 |
import Control.Applicative |
|
41 |
import System.Time (ClockTime(..)) |
|
42 |
|
|
40 | 43 |
import Test.QuickCheck as QuickCheck hiding (Result) |
41 | 44 |
import Test.HUnit |
42 | 45 |
import qualified Text.JSON as J |
... | ... | |
54 | 57 |
|
55 | 58 |
-- * Arbitrary instance |
56 | 59 |
|
60 |
instance Arbitrary ClockTime where |
|
61 |
arbitrary = TOD <$> arbitrary <*> fmap (`mod` (10^(12::Int))) arbitrary |
|
62 |
|
|
57 | 63 |
instance (Arbitrary a, Ord a, Num a, Show a) => |
58 | 64 |
Arbitrary (Types.Positive a) where |
59 | 65 |
arbitrary = do |
Also available in: Unified diff