root / test / hs / Test / Ganeti / THH / Types.hs @ 63571096
History | View | Annotate | Download (1.8 kB)
1 |
{-# LANGUAGE TemplateHaskell #-} |
---|---|
2 |
{-# OPTIONS_GHC -fno-warn-orphans #-} |
3 |
|
4 |
{-| Unittests for 'Ganeti.THH.Types'. |
5 |
|
6 |
-} |
7 |
|
8 |
{- |
9 |
|
10 |
Copyright (C) 2014 Google Inc. |
11 |
|
12 |
This program is free software; you can redistribute it and/or modify |
13 |
it under the terms of the GNU General Public License as published by |
14 |
the Free Software Foundation; either version 2 of the License, or |
15 |
(at your option) any later version. |
16 |
|
17 |
This program is distributed in the hope that it will be useful, but |
18 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
19 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 |
General Public License for more details. |
21 |
|
22 |
You should have received a copy of the GNU General Public License |
23 |
along with this program; if not, write to the Free Software |
24 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
25 |
02110-1301, USA. |
26 |
|
27 |
-} |
28 |
|
29 |
module Test.Ganeti.THH.Types |
30 |
( testTHH_Types |
31 |
) where |
32 |
|
33 |
import Test.QuickCheck as QuickCheck hiding (Result) |
34 |
import qualified Text.JSON as J |
35 |
|
36 |
import Test.Ganeti.TestCommon |
37 |
import Test.Ganeti.TestHelper |
38 |
|
39 |
import Ganeti.THH.Types |
40 |
|
41 |
{-# ANN module "HLint: ignore Use camelCase" #-} |
42 |
|
43 |
-- * Instances |
44 |
|
45 |
instance Arbitrary a => Arbitrary (OneTuple a) where |
46 |
arbitrary = fmap OneTuple arbitrary |
47 |
|
48 |
-- * Properties |
49 |
|
50 |
-- | Tests OneTuple serialisation. |
51 |
prop_OneTuple_serialisation :: OneTuple String -> Property |
52 |
prop_OneTuple_serialisation = testSerialisation |
53 |
|
54 |
-- | Tests OneTuple doesn't deserialize wrong input. |
55 |
prop_OneTuple_deserialisationFail :: Property |
56 |
prop_OneTuple_deserialisationFail = |
57 |
conjoin . map (testDeserialisationFail (OneTuple "")) $ |
58 |
[ J.JSArray [] |
59 |
, J.JSArray [J.showJSON "a", J.showJSON "b"] |
60 |
, J.JSArray [J.showJSON (1 :: Int)] |
61 |
] |
62 |
|
63 |
|
64 |
-- * Test suite |
65 |
|
66 |
testSuite "THH_Types" |
67 |
[ 'prop_OneTuple_serialisation |
68 |
, 'prop_OneTuple_deserialisationFail |
69 |
] |