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/ProgenyUnitTest.cpp $ 00003 // $Id: ProgenyUnitTest.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 Progeny class. 00018 00019 #include <boost/test/unit_test.hpp> 00020 #include "torc/physical/Factory.hpp" 00021 #include "torc/physical/Pip.hpp" 00022 00023 namespace torc { 00024 namespace physical { 00025 00026 BOOST_AUTO_TEST_SUITE(physical) 00027 00028 /// \cond OMIT_FROM_DOXYGEN 00029 class A : public Progenitor<class A> {}; 00030 class B : public Progeny<class A> {}; 00031 /// \endcond 00032 00033 /// \brief Unit test for the Progeny class. 00034 BOOST_AUTO_TEST_CASE(ProgenyUnitTest) { 00035 // create an accessory progenitor 00036 typedef Progenitor<A> progenitor_t; 00037 progenitor_t::SharedPtrType progenitorPtr(new A()); 00038 BOOST_REQUIRE(progenitorPtr.get() != 0); 00039 progenitorPtr->setSelfWeakPtr(progenitorPtr); 00040 00041 // functions tested: 00042 // Progeny(void); 00043 // Progeny(const WeakPtrType& inParentPtr); 00044 // void setParentWeakPtr(WeakPtrType inParentPtr); 00045 // const WeakPtrType& getParentWeakPtr(void) const; 00046 // void resetParentWeakPtr(void); 00047 B progeny1; 00048 B progeny2/*(progenitorPtr)*/; 00049 BOOST_CHECK_EQUAL(progeny1.getParentWeakPtr().expired(), true); 00050 BOOST_CHECK_EQUAL(progeny2.getParentWeakPtr().expired(), true); 00051 progeny2.setParentWeakPtr(progenitorPtr); 00052 BOOST_CHECK_EQUAL(progeny2.getParentWeakPtr().expired(), false); 00053 BOOST_CHECK(progeny2.getParentWeakPtr().lock() == progenitorPtr); 00054 progeny1.setParentWeakPtr(progeny2.getParentWeakPtr()); 00055 progeny2.resetParentWeakPtr(); 00056 BOOST_CHECK(progeny1.getParentWeakPtr().lock() == progenitorPtr); 00057 BOOST_CHECK_EQUAL(progeny1.getParentWeakPtr().expired(), false); 00058 BOOST_CHECK_EQUAL(progeny2.getParentWeakPtr().expired(), true); 00059 00060 // functions broken: 00061 // const SharedPtrType& getParentSharedPtr(void) const; 00062 //const progenitor_t::SharedPtrType otherPtr(progeny1.getParentSharedPtr()); 00063 } 00064 00065 BOOST_AUTO_TEST_SUITE_END() 00066 00067 } // namespace physical 00068 } // namespace torc
1.5.6