Debian Codegraph @

test/hs/Test/Ganeti/Constants.hs

raw
1 {-# LANGUAGE TemplateHaskell #-}
2 {-| Unittests for constants
3
4 -}
5
6 {-
7
8 Copyright (C) 2013 Google Inc.
9 All rights reserved.
10
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are
13 met:
14
15 1. Redistributions of source code must retain the above copyright notice,
16 this list of conditions and the following disclaimer.
17
18 2. Redistributions in binary form must reproduce the above copyright
19 notice, this list of conditions and the following disclaimer in the
20 documentation and/or other materials provided with the distribution.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
23 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34 -}
35
36 module Test.Ganeti.Constants (testConstants) where
37
38 import Test.HUnit (Assertion)
39 import qualified Test.HUnit as HUnit
40
41 import qualified Ganeti.Constants as Constants
42 import qualified Ganeti.ConstantUtils as ConstantUtils
43 import qualified Test.Ganeti.TestHelper as TestHelper
44
45 {-# ANN module "HLint: ignore Use camelCase" #-}
46
47 case_buildVersion :: Assertion
48 case_buildVersion = do
49 HUnit.assertBool "Config major lower-bound violation"
50 (Constants.configMajor >= 0)
51 HUnit.assertBool "Config major upper-bound violation"
52 (Constants.configMajor <= 99)
53 HUnit.assertBool "Config minor lower-bound violation"
54 (Constants.configMinor >= 0)
55 HUnit.assertBool "Config minor upper-bound violation"
56 (Constants.configMinor <= 99)
57 HUnit.assertBool "Config revision lower-bound violation"
58 (Constants.configRevision >= 0)
59 HUnit.assertBool "Config revision upper-bound violation"
60 (Constants.configRevision <= 9999)
61 HUnit.assertBool "Config version lower-bound violation"
62 (Constants.configVersion >= 0)
63 HUnit.assertBool "Config version upper-bound violation"
64 (Constants.configVersion <= 99999999)
65 HUnit.assertEqual "Build version"
66 (ConstantUtils.buildVersion 0 0 0) 0
67 HUnit.assertEqual "Build version"
68 (ConstantUtils.buildVersion 10 10 1010) 10101010
69 HUnit.assertEqual "Build version"
70 (ConstantUtils.buildVersion 12 34 5678) 12345678
71 HUnit.assertEqual "Build version"
72 (ConstantUtils.buildVersion 99 99 9999) 99999999
73 HUnit.assertEqual "Build version"
74 (ConstantUtils.buildVersion
75 Constants.configMajor
76 Constants.configMinor
77 Constants.configRevision) Constants.configVersion
78 HUnit.assertEqual "Build version"
79 (ConstantUtils.buildVersion
80 Constants.configMajor
81 Constants.configMinor
82 Constants.configRevision) Constants.protocolVersion
83
84 TestHelper.testSuite "Constants"
85 [ 'case_buildVersion
86 ]