torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NamedUnitTest.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 Named class.
18 
19 #include <boost/test/unit_test.hpp>
20 #include "torc/physical/Named.hpp"
21 
22 namespace torc {
23 namespace physical {
24 
25 BOOST_AUTO_TEST_SUITE(physical)
26 
27 /// \brief Unit test for the Named class.
28 BOOST_AUTO_TEST_CASE(NamedUnitTest) {
29  // functions tested:
30  // Named(const string& inName);
31  // const string& getName(void) const;
32  // bool operator ==(const Named& rhs) const;
33  // create two Named objects
34  std::string name1 = "name1";
35  std::string name2 = "name2";
36  Named named1(name1);
37  Named named2(name2);
38  BOOST_CHECK(named1.getName() == name1);
39  BOOST_CHECK_EQUAL(named1 == named2, false);
40 
41  // functions tested:
42  // NameComparator(const string& inName);
43  // bool operator() (const Named& inNamed) const;
44  // bool operator() (const NamedSharedPtr& inNamedPtr) const;
45  // compare Named objects with a comparator
46  NameComparator comparator(name1);
47  NamedSharedPtr named1Ptr = NamedSharedPtr(new Named(name1));
48  BOOST_CHECK_EQUAL(comparator(named1Ptr), true);
49  BOOST_CHECK_EQUAL(comparator(named1), true);
50  BOOST_CHECK_EQUAL(comparator(named2), false);
51 }
52 
53 BOOST_AUTO_TEST_SUITE_END()
54 
55 } // namespace physical
56 } // namespace torc
Concept for any object that can be named.
Definition: Named.hpp:36
std::string string
BOOST_AUTO_TEST_CASE(XdlUnpackUnitTest)
Unit test for the XdlUnpack class.
boost::shared_ptr< Named > NamedSharedPtr
Shared pointer encapsulation of a Named object.
Definition: Named.hpp:58
Comparator class to serve as a predicate when searching for names.
Definition: Named.hpp:61
Header for the Named class.
const string & getName(void) const
Returns the object name.
Definition: Named.hpp:51