aboutsummaryrefslogtreecommitdiffstats
path: root/tests/libsample
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-09-24 11:25:41 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:07:19 -0300
commit85f926e8fef29967393a11832ac26cafecc9b777 (patch)
treed547a700b60a3bfa3f27c5fbc7cdffe2a60fd27b /tests/libsample
parenta0bd7044da2150e096ab197302b5c77a845c8682 (diff)
Created unit test to unsafe parent (parent created from c++)
Reviewer: Hugo Parente Lima <hugo.pl@gmail.com> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/libsample')
-rw-r--r--tests/libsample/objecttype.cpp14
-rw-r--r--tests/libsample/objecttype.h5
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/libsample/objecttype.cpp b/tests/libsample/objecttype.cpp
index c1407d237..e4fce71e3 100644
--- a/tests/libsample/objecttype.cpp
+++ b/tests/libsample/objecttype.cpp
@@ -25,6 +25,7 @@
#include <algorithm>
#include <iostream>
#include <string>
+#include <assert.h>
using namespace std;
@@ -269,3 +270,16 @@ int ObjectType::callId() const
return m_call_id;
}
+
+void ObjectType::callVirtualCreateChild()
+{
+ ObjectType* fake_parent = new ObjectType();
+ ObjectType* fake_child = createChild(fake_parent);
+ assert(fake_child->isPython());
+ delete fake_parent;
+}
+
+ObjectType* ObjectType::createChild(ObjectType* parent)
+{
+ return new ObjectType(parent);
+}
diff --git a/tests/libsample/objecttype.h b/tests/libsample/objecttype.h
index b09b402e7..bb7787e44 100644
--- a/tests/libsample/objecttype.h
+++ b/tests/libsample/objecttype.h
@@ -102,6 +102,11 @@ public:
void setObject(const Null&);
int callId() const;
+ //Function used to create a parent from C++
+ virtual bool isPython() { return false; }
+ void callVirtualCreateChild();
+ virtual ObjectType* createChild(ObjectType* parent);
+
private:
ObjectType(const ObjectType&);
ObjectType& operator=(const ObjectType&);