00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/physical/NamedUnitTest.cpp $ 00003 // $Id: NamedUnitTest.cpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Unit test for the Named class. 00018 00019 #include <boost/test/unit_test.hpp> 00020 #include "torc/physical/Named.hpp" 00021 00022 namespace torc { 00023 namespace physical { 00024 00025 BOOST_AUTO_TEST_SUITE(physical) 00026 00027 /// \brief Unit test for the Named class. 00028 BOOST_AUTO_TEST_CASE(NamedUnitTest) { 00029 // functions tested: 00030 // Named(const string& inName); 00031 // const string& getName(void) const; 00032 // bool operator ==(const Named& rhs) const; 00033 // create two Named objects 00034 std::string name1 = "name1"; 00035 std::string name2 = "name2"; 00036 Named named1(name1); 00037 Named named2(name2); 00038 BOOST_CHECK(named1.getName() == name1); 00039 BOOST_CHECK_EQUAL(named1 == named2, false); 00040 00041 // functions tested: 00042 // NameComparator(const string& inName); 00043 // bool operator() (const Named& inNamed) const; 00044 // bool operator() (const NamedSharedPtr& inNamedPtr) const; 00045 // compare Named objects with a comparator 00046 NameComparator comparator(name1); 00047 NamedSharedPtr named1Ptr = NamedSharedPtr(new Named(name1)); 00048 BOOST_CHECK_EQUAL(comparator(named1Ptr), true); 00049 BOOST_CHECK_EQUAL(comparator(named1), true); 00050 BOOST_CHECK_EQUAL(comparator(named2), false); 00051 } 00052 00053 BOOST_AUTO_TEST_SUITE_END() 00054 00055 } // namespace physical 00056 } // namespace torc