Revision 91f0dc1e test/hs/Test/Ganeti/TestCommon.hs
b/test/hs/Test/Ganeti/TestCommon.hs | ||
---|---|---|
60 | 60 |
, genLuxiTagName |
61 | 61 |
, netmask2NumHosts |
62 | 62 |
, testSerialisation |
63 |
, testArraySerialisation |
|
63 | 64 |
, testDeserialisationFail |
64 | 65 |
, resultProp |
65 | 66 |
, readTestData |
... | ... | |
93 | 94 |
import Numeric |
94 | 95 |
|
95 | 96 |
import qualified Ganeti.BasicTypes as BasicTypes |
97 |
import Ganeti.JSON (ArrayObject(..)) |
|
96 | 98 |
import Ganeti.Types |
97 | 99 |
|
98 | 100 |
-- * Constants |
... | ... | |
374 | 376 |
J.Error msg -> failTest $ "Failed to deserialise: " ++ msg |
375 | 377 |
J.Ok a' -> a ==? a' |
376 | 378 |
|
379 |
-- | Checks for array serialisation idempotence. |
|
380 |
testArraySerialisation :: (Eq a, Show a, ArrayObject a) => a -> Property |
|
381 |
testArraySerialisation a = |
|
382 |
case fromJSArray (toJSArray a) of |
|
383 |
J.Error msg -> failTest $ "Failed to deserialise: " ++ msg |
|
384 |
J.Ok a' -> a ==? a' |
|
385 |
|
|
377 | 386 |
-- | Checks if the deserializer doesn't accept forbidden values. |
378 | 387 |
-- The first argument is ignored, it just enforces the correct type. |
379 | 388 |
testDeserialisationFail :: (Eq a, Show a, J.JSON a) |
Also available in: Unified diff