torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ConfigUnitTest.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 Config class.
18 
19 #include <boost/test/unit_test.hpp>
20 #include "torc/physical/Config.hpp"
21 
22 namespace torc {
23 namespace physical {
24 
25 BOOST_AUTO_TEST_SUITE(physical)
26 
27 /// \brief Unit test for the Config class.
28 BOOST_AUTO_TEST_CASE(ConfigUnitTest) {
29  // functions tested:
30  // Config(const string& inName, const string& inValue);
31  // Config(const string& inName, const string& inValue, SequenceIndex inOrder);
32  // Config(void);
33  // create a config
34  std::string name1 = "name1";
35  std::string name2 = "name2";
36  std::string name3 = "name3";
37  std::string value1 = "value1";
38  std::string value2 = "value2";
39  std::string value3 = "value3";
40  SequenceIndex order1(0);
41  SequenceIndex order2(9);
42  SequenceIndex order3(10);
43  Config config1(name1, value1);
44  Config config2("name3", "value3", order2);
45  Config config3;
46 
47  // functions tested:
48  // const string& Named::getName(void) const;
49  // const string& getValue(void) const;
50  // SequenceIndex getOrder(void) const;
51  // void setOrder(SequenceIndex inOrder);
52  BOOST_CHECK_EQUAL(config1.getName(), name1);
53  BOOST_CHECK_EQUAL(config1.getValue(), value1);
54  config3.setOrder(order3);
55  BOOST_CHECK(config1.getOrder() == order1);
56  BOOST_CHECK(config2.getOrder() == order2);
57  BOOST_CHECK(config3.getOrder() == order3);
58 
59  // functions tested:
60  // void setValue(const string& inValue);
61  // void setName(const string& inName);
62  // const string& Named::getName(void) const;
63  // const string& getValue(void) const;
64  config1.setName(name2);
65  config1.setValue(value2);
66  BOOST_CHECK_EQUAL(config1.getName(), name2);
67  BOOST_CHECK_EQUAL(config1.getValue(), value2);
68 
69  // functions tested:
70  // bool operator ==(const Config& rhs) const;
71  BOOST_CHECK((config1 == config2) == false);
72 }
73 
74 BOOST_AUTO_TEST_SUITE_END()
75 
76 } // namespace physical
77 } // namespace torc
boost::uint64_t SequenceIndex
Typedef for generic sequences.
void setOrder(SequenceIndex inOrder)
Set the sequence index for this configuration.
Definition: Config.hpp:65
Header for the Config class.
std::string string
BOOST_AUTO_TEST_CASE(XdlUnpackUnitTest)
Unit test for the XdlUnpack class.
Configuration. A {name:value} pair.
Definition: Config.hpp:39
const string & getName(void) const
Returns the object name.
Definition: Named.hpp:51
const string & getValue(void) const
Return the configuration value.
Definition: Config.hpp:86
void setValue(const string &inValue)
Set the configuration value.
Definition: Config.hpp:90
void setName(const string &inName)
Sets the object name.
Definition: Config.hpp:94
SequenceIndex getOrder(void) const
Return the configuration sequence index.
Definition: Config.hpp:88