Statistics
| Branch: | Tag: | Revision:

root / test / hs / Test / Ganeti / Constants.hs @ 285d04a1

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
case_buildVersion :: Assertion
37
case_buildVersion = do
38
  HUnit.assertBool "Config major lower-bound violation"
39
                   (Constants.configMajor >= 0)
40
  HUnit.assertBool "Config major upper-bound violation"
41
                   (Constants.configMajor <= 99)
42
  HUnit.assertBool "Config minor lower-bound violation"
43
                   (Constants.configMinor >= 0)
44
  HUnit.assertBool "Config minor upper-bound violation"
45
                   (Constants.configMinor <= 99)
46
  HUnit.assertBool "Config revision lower-bound violation"
47
                   (Constants.configRevision >= 0)
48
  HUnit.assertBool "Config revision upper-bound violation"
49
                   (Constants.configRevision <= 9999)
50
  HUnit.assertBool "Config version lower-bound violation"
51
                   (Constants.configVersion >= 0)
52
  HUnit.assertBool "Config version upper-bound violation"
53
                   (Constants.configVersion <= 99999999)
54
  HUnit.assertEqual "Build version"
55
                    (ConstantUtils.buildVersion 0 0 0) 0
56
  HUnit.assertEqual "Build version"
57
                    (ConstantUtils.buildVersion 10 10 1010) 10101010
58
  HUnit.assertEqual "Build version"
59
                    (ConstantUtils.buildVersion 12 34 5678) 12345678
60
  HUnit.assertEqual "Build version"
61
                    (ConstantUtils.buildVersion 99 99 9999) 99999999
62
  HUnit.assertEqual "Build version"
63
                    (ConstantUtils.buildVersion
64
                     Constants.configMajor
65
                     Constants.configMinor
66
                     Constants.configRevision) Constants.configVersion
67
  HUnit.assertEqual "Build version"
68
                    (ConstantUtils.buildVersion
69
                     Constants.configMajor
70
                     Constants.configMinor
71
                     Constants.configRevision) Constants.protocolVersion
72

    
73
TestHelper.testSuite "Constants"
74
  [ 'case_buildVersion
75
  ]