torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DottedVersionUnitTest.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Unit test for the DottedVersion class.
18 
19 #include <boost/test/unit_test.hpp>
21 #include "torc/Version.hpp"
22 
23 namespace torc {
24 namespace common {
25 
26 BOOST_AUTO_TEST_SUITE(common)
27 
28 /// \brief Unit test for the DottedVersion class.
29 BOOST_AUTO_TEST_CASE(DottedVersionUnitTest) {
30  // functions tested:
31  // DottedVersion(uint8_t inMajor = 0, uint8_t inMinor = 0, uint8_t inRevision = 0,
32  // uint8_t inReserved = 0);
33  // members tested:
34  // uint8_t mMajor;
35  // uint8_t mMinor;
36  // uint8_t mRevision;
37  // uint8_t mReserved;
38  DottedVersion version(1, 2, 3, 4);
39  BOOST_CHECK_EQUAL(version.mMajor, 1);
40  BOOST_CHECK_EQUAL(version.mMinor, 2);
41  BOOST_CHECK_EQUAL(version.mRevision, 3);
42  BOOST_CHECK_EQUAL(version.mReserved, 4);
43  BOOST_CHECK(version == DottedVersion(1, 2, 3));
44  BOOST_CHECK(version < DottedVersion(1, 2, 4));
45  BOOST_CHECK(version < DottedVersion(1, 3, 3));
46  BOOST_CHECK(version < DottedVersion(2, 2, 3));
47  BOOST_CHECK(version <= DottedVersion(1, 2, 3));
48  BOOST_CHECK(version <= DottedVersion(1, 2, 4));
49  BOOST_CHECK(version <= DottedVersion(1, 3, 3));
50  BOOST_CHECK(version <= DottedVersion(2, 2, 3));
51  BOOST_CHECK(version > DottedVersion(0, 2, 3));
52  BOOST_CHECK(version > DottedVersion(1, 1, 3));
53  BOOST_CHECK(version > DottedVersion(1, 2, 2));
54  BOOST_CHECK(version >= DottedVersion(1, 2, 3));
55  BOOST_CHECK(version >= DottedVersion(0, 2, 3));
56  BOOST_CHECK(version >= DottedVersion(1, 1, 3));
57  BOOST_CHECK(version >= DottedVersion(1, 2, 2));
58  /// \todo Update the list of members tested, and add Doxygen comments to the header file.
59 
60  // just for fun, we'll check the Torc version
61  BOOST_CHECK(torc::cTorcVersion >= DottedVersion(0, 9, 0));
62 }
63 
64 BOOST_AUTO_TEST_SUITE_END()
65 
66 } // namespace common
67 } // namespace torc
Header for the DottedVersion class.
BOOST_AUTO_TEST_CASE(AnnotatedUnitTest)
Unit test for the Annotated class.
const torc::common::DottedVersion cTorcVersion(1, 0, 1)
The current Torc version as a DottedVersion object.
Definition: Version.hpp:28
Header for the Torc version data.
Encapsulation of dotted decimal DottedVersion numbers.