]> granicus.if.org Git - icinga2/blob - test/base-object.cpp
Merge pull request #6999 from Icinga/bugfix/compiler-warnings
[icinga2] / test / base-object.cpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #include "base/object.hpp"
4 #include "base/value.hpp"
5 #include <BoostTestTargetConfig.h>
6
7 using namespace icinga;
8
9 class TestObject : public Object
10 {
11 public:
12         DECLARE_PTR_TYPEDEFS(TestObject);
13
14         TestObject::Ptr GetTestRef()
15         {
16                 return this;
17         }
18 };
19
20 BOOST_AUTO_TEST_SUITE(base_object)
21
22 BOOST_AUTO_TEST_CASE(construct)
23 {
24         Object::Ptr tobject = new TestObject();
25         BOOST_CHECK(tobject);
26 }
27
28 BOOST_AUTO_TEST_CASE(getself)
29 {
30         TestObject::Ptr tobject = new TestObject();
31         TestObject::Ptr tobject_self = tobject->GetTestRef();
32         BOOST_CHECK(tobject == tobject_self);
33
34         Value vobject = tobject;
35         BOOST_CHECK(!vobject.IsEmpty());
36         BOOST_CHECK(vobject.IsObjectType<TestObject>());
37 }
38
39 BOOST_AUTO_TEST_SUITE_END()