summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2017-04-09 12:25:59 +0200
committerMurray Cumming <murrayc@murrayc.com>2017-04-15 14:16:50 +0200
commit0aa8c79f09e407087596158693f3a3098ad6aa5e (patch)
tree6d513cb457cf90bb5734d0dbc6fe1588be26a6e6 /tests
parent80e02100f34414c6bdd46ddc4dad5117b7547743 (diff)
downloadglibmm-0aa8c79f09e407087596158693f3a3098ad6aa5e.tar.gz
Value: Only use RefPtr specialization for types that have get_base_type().
For instance, RefPtr to ObjectBase-derived types, or other types that try to have a similar API. Previously, this assumed that any Value<RefPtr<T>> was for a T that had a get_base_type() (wrapping an underlying glib/gtk C type).
Diffstat (limited to 'tests')
-rw-r--r--tests/glibmm_value/main.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/glibmm_value/main.cc b/tests/glibmm_value/main.cc
index 47da4645..a824f948 100644
--- a/tests/glibmm_value/main.cc
+++ b/tests/glibmm_value/main.cc
@@ -78,6 +78,10 @@ test()
Glib::init();
+ // TODO: Put this test, of internal stuff, somewhere else.
+ static_assert(Glib::Traits::HasGetBaseType<DerivedObject, GType()>::value,
+ "DerivedObject has no get_base_type().");
+
// RefPtr to Glib::ObjectBase-derived type:
{
GObject* gobject = G_OBJECT(g_object_new(TEST_TYPE_DERIVED, nullptr));
@@ -114,6 +118,29 @@ test()
const auto v = value.get();
assert(v);
}
+
+ {
+ auto foo = std::make_shared<Foo>();
+
+ // custom pointer
+ Glib::Value<std::shared_ptr<Foo>> value;
+ value.init(Glib::Value<std::shared_ptr<Foo>>::value_type()); // TODO: Avoid this step?
+ value.set(foo);
+
+ const auto v = value.get();
+ assert(v);
+ }
+
+ {
+ auto foo = std::make_shared<Foo>();
+
+ Glib::Value<std::shared_ptr<const Foo>> value;
+ value.init(Glib::Value<std::shared_ptr<const Foo>>::value_type()); // TODO: Avoid this step?
+ value.set(foo);
+
+ const auto v = value.get();
+ assert(v);
+ }
}
// Glib::Object RefPtr<>