summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2017-04-09 12:57:42 +0200
committerMurray Cumming <murrayc@murrayc.com>2017-04-09 14:24:18 +0200
commitb98b57b647c4475031b17c793336b490900198bc (patch)
tree62c1375d111f41fef58ccafd612c9d5c0985e617
parent696685eeaa639ae5e41a9eaa761250368af492db (diff)
downloadglibmm-b98b57b647c4475031b17c793336b490900198bc.tar.gz
tests: glibmm_value: Test RefPtr-to-ObjectBase.
-rw-r--r--tests/glibmm_value/main.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/glibmm_value/main.cc b/tests/glibmm_value/main.cc
index 51e645fa..47da4645 100644
--- a/tests/glibmm_value/main.cc
+++ b/tests/glibmm_value/main.cc
@@ -1,3 +1,4 @@
+#include "../glibmm_object/test_derived_object.h"
#include <glibmm.h>
#include <cassert>
@@ -74,6 +75,45 @@ test()
const auto v = value.get();
assert(v);
}
+
+ Glib::init();
+
+ // RefPtr to Glib::ObjectBase-derived type:
+ {
+ GObject* gobject = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr));
+ auto derived = Glib::make_refptr_for_instance(new DerivedObject(gobject, 5));
+
+ using ValueType = Glib::Value<Glib::RefPtr<DerivedObject>>;
+ ValueType value;
+ value.init(ValueType::value_type()); // TODO: Avoid this step?
+
+ // Check that value_type() returns the type of the underlying GObjectBase,
+ // not a custom GType for the Glib::RefPtr:
+ assert(ValueType::value_type() == DerivedObject::get_base_type());
+
+ value.set(derived);
+
+ const auto v = value.get();
+ assert(v);
+ }
+
+ {
+ GObject* gobject = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr));
+ auto derived = Glib::make_refptr_for_instance(new DerivedObject(gobject, 5));
+
+ using ValueType = Glib::Value<Glib::RefPtr<const DerivedObject>>;
+ ValueType value;
+ value.init(ValueType::value_type()); // TODO: Avoid this step?
+
+ // Check that value_type() returns the type of the underlying GObjectBase,
+ // not a custom GType for the Glib::RefPtr:
+ assert(ValueType::value_type() == DerivedObject::get_base_type());
+
+ value.set(derived);
+
+ const auto v = value.get();
+ assert(v);
+ }
}
// Glib::Object RefPtr<>