changed: gcc8 base update
[opensg.git] / Source / System / FieldContainer / Base / OSGMTRefCountPtrTest.cpp
blobccd286897f89b99e5bdbf10df03c19a9b446658f
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright 2009 by OpenSG Forum *
6 * *
7 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
8 * *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
11 * License *
12 * *
13 * This library is free software; you can redistribute it and/or modify it *
14 * under the terms of the GNU Library General Public License as published *
15 * by the Free Software Foundation, version 2. *
16 * *
17 * This library is distributed in the hope that it will be useful, but *
18 * WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
20 * Library General Public License for more details. *
21 * *
22 * You should have received a copy of the GNU Library General Public *
23 * License along with this library; if not, write to the Free Software *
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
25 * *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
28 * Changes *
29 * *
30 * *
31 * *
32 * *
33 * *
34 * *
35 \*---------------------------------------------------------------------------*/
37 #include <UnitTest++.h>
39 #include "OSGFieldContainer.h"
40 #include "OSGNode.h"
41 #include "OSGNodeCore.h"
42 #include "OSGGroup.h"
44 OSG_BEGIN_NAMESPACE
45 OSG_GEN_CONTAINERPTR(FieldContainer);
46 OSG_END_NAMESPACE
48 SUITE(MTRefCountPtrTests)
51 TEST(Basics)
53 OSG::NodeMTRefPtr n0 = OSG::Node ::create();
54 OSG::GroupMTRefPtr g0 = OSG::Group::create();
56 n0->setCore(g0);
58 OSG::commitChanges();
60 g0 = NULL;
62 CHECK(n0 != NULL);
63 CHECK(n0->getCore() != NULL);
65 n0 = NULL;
67 CHECK_EQUAL(static_cast<OSG::FieldContainer *>(NULL), n0);
68 CHECK_EQUAL(static_cast<OSG::FieldContainer *>(NULL), g0);
72 TEST(VectorFind)
74 OSG::NodeMTRefPtr n0 = OSG::Node::create();
75 OSG::NodeMTRefPtr n1 = OSG::Node::create();
76 OSG::NodeMTRefPtr n2 = OSG::Node::create();
78 OSG::GroupMTRefPtr g0 = OSG::Group::create();
79 OSG::GroupMTRefPtr g1 = OSG::Group::create();
80 OSG::GroupMTRefPtr g2 = OSG::Group::create();
82 OSG::FieldContainer *fc = g1;
84 typedef std::vector<OSG::FieldContainerMTRefPtr> FCMTStore;
85 FCMTStore fcStore;
87 fcStore.push_back(n0);
88 fcStore.push_back(n1);
89 fcStore.push_back(n2);
91 fcStore.push_back(g0);
92 fcStore.push_back(g1);
93 fcStore.push_back(g2);
95 FCMTStore::iterator fcIt;
97 fcIt = std::find(fcStore.begin(), fcStore.end(), fc);
99 CHECK(fcIt != fcStore.end());
100 CHECK(fc == *fcIt);
101 CHECK(g1 == *fcIt);
102 CHECK(std::distance(fcStore.begin(), fcIt) == 4);
106 } // SUITE(MTRefCountPtrTests)