root / test / hs / Test / Ganeti / Constants.hs @ f89ec0e0
History | View | Annotate | Download (2.9 kB)
1 |
{-# LANGUAGE TemplateHaskell #-} |
---|---|
2 |
{-| Unittests for constants |
3 |
|
4 |
-} |
5 |
|
6 |
{- |
7 |
|
8 |
Copyright (C) 2013 Google Inc. |
9 |
|
10 |
This program is free software; you can redistribute it and/or modify |
11 |
it under the terms of the GNU General Public License as published by |
12 |
the Free Software Foundation; either version 2 of the License, or |
13 |
(at your option) any later version. |
14 |
|
15 |
This program is distributed in the hope that it will be useful, but |
16 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 |
General Public License for more details. |
19 |
|
20 |
You should have received a copy of the GNU General Public License |
21 |
along with this program; if not, write to the Free Software |
22 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
23 |
02110-1301, USA. |
24 |
|
25 |
-} |
26 |
|
27 |
module Test.Ganeti.Constants (testConstants) where |
28 |
|
29 |
import Test.HUnit (Assertion) |
30 |
import qualified Test.HUnit as HUnit |
31 |
|
32 |
import qualified Ganeti.Constants as Constants |
33 |
import qualified Ganeti.ConstantUtils as ConstantUtils |
34 |
import qualified Test.Ganeti.TestHelper as TestHelper |
35 |
|
36 |
{-# ANN module "HLint: ignore Use camelCase" #-} |
37 |
|
38 |
case_buildVersion :: Assertion |
39 |
case_buildVersion = do |
40 |
HUnit.assertBool "Config major lower-bound violation" |
41 |
(Constants.configMajor >= 0) |
42 |
HUnit.assertBool "Config major upper-bound violation" |
43 |
(Constants.configMajor <= 99) |
44 |
HUnit.assertBool "Config minor lower-bound violation" |
45 |
(Constants.configMinor >= 0) |
46 |
HUnit.assertBool "Config minor upper-bound violation" |
47 |
(Constants.configMinor <= 99) |
48 |
HUnit.assertBool "Config revision lower-bound violation" |
49 |
(Constants.configRevision >= 0) |
50 |
HUnit.assertBool "Config revision upper-bound violation" |
51 |
(Constants.configRevision <= 9999) |
52 |
HUnit.assertBool "Config version lower-bound violation" |
53 |
(Constants.configVersion >= 0) |
54 |
HUnit.assertBool "Config version upper-bound violation" |
55 |
(Constants.configVersion <= 99999999) |
56 |
HUnit.assertEqual "Build version" |
57 |
(ConstantUtils.buildVersion 0 0 0) 0 |
58 |
HUnit.assertEqual "Build version" |
59 |
(ConstantUtils.buildVersion 10 10 1010) 10101010 |
60 |
HUnit.assertEqual "Build version" |
61 |
(ConstantUtils.buildVersion 12 34 5678) 12345678 |
62 |
HUnit.assertEqual "Build version" |
63 |
(ConstantUtils.buildVersion 99 99 9999) 99999999 |
64 |
HUnit.assertEqual "Build version" |
65 |
(ConstantUtils.buildVersion |
66 |
Constants.configMajor |
67 |
Constants.configMinor |
68 |
Constants.configRevision) Constants.configVersion |
69 |
HUnit.assertEqual "Build version" |
70 |
(ConstantUtils.buildVersion |
71 |
Constants.configMajor |
72 |
Constants.configMinor |
73 |
Constants.configRevision) Constants.protocolVersion |
74 |
|
75 |
TestHelper.testSuite "Constants" |
76 |
[ 'case_buildVersion |
77 |
] |