torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProgenyUnitTest.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 Progeny class.
18 
19 #include <boost/test/unit_test.hpp>
21 #include "torc/physical/Pip.hpp"
22 
23 namespace torc {
24 namespace physical {
25 
26 BOOST_AUTO_TEST_SUITE(physical)
27 
28 /// \cond OMIT_FROM_DOXYGEN
29 class A : public Progenitor<class A> {};
30 class B : public Progeny<class A> {};
31 /// \endcond
32 
33 /// \brief Unit test for the Progeny class.
34 BOOST_AUTO_TEST_CASE(ProgenyUnitTest) {
35  // create an accessory progenitor
36  typedef Progenitor<A> progenitor_t;
37  progenitor_t::SharedPtrType progenitorPtr(new A());
38  BOOST_REQUIRE(progenitorPtr.get() != 0);
39  progenitorPtr->setSelfWeakPtr(progenitorPtr);
40 
41  // functions tested:
42  // Progeny(void);
43  // Progeny(const WeakPtrType& inParentPtr);
44  // void setParentWeakPtr(WeakPtrType inParentPtr);
45  // const WeakPtrType& getParentWeakPtr(void) const;
46  // void resetParentWeakPtr(void);
47  B progeny1;
48  B progeny2/*(progenitorPtr)*/;
49  BOOST_CHECK_EQUAL(progeny1.getParentWeakPtr().expired(), true);
50  BOOST_CHECK_EQUAL(progeny2.getParentWeakPtr().expired(), true);
51  progeny2.setParentWeakPtr(progenitorPtr);
52  BOOST_CHECK_EQUAL(progeny2.getParentWeakPtr().expired(), false);
53  BOOST_CHECK(progeny2.getParentWeakPtr().lock() == progenitorPtr);
54  progeny1.setParentWeakPtr(progeny2.getParentWeakPtr());
55  progeny2.resetParentWeakPtr();
56  BOOST_CHECK(progeny1.getParentWeakPtr().lock() == progenitorPtr);
57  BOOST_CHECK_EQUAL(progeny1.getParentWeakPtr().expired(), false);
58  BOOST_CHECK_EQUAL(progeny2.getParentWeakPtr().expired(), true);
59 
60  // functions broken:
61  // const SharedPtrType& getParentSharedPtr(void) const;
62  //const progenitor_t::SharedPtrType otherPtr(progeny1.getParentSharedPtr());
63 }
64 
65 BOOST_AUTO_TEST_SUITE_END()
66 
67 } // namespace physical
68 } // namespace torc
BOOST_AUTO_TEST_CASE(XdlUnpackUnitTest)
Unit test for the XdlUnpack class.
Concept for any object that may have children.
Definition: Progenitor.hpp:36
Header for the Pip class.
Header for the Factory class.