summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2017-04-07 21:49:28 +0200
committerMurray Cumming <murrayc@murrayc.com>2017-04-07 21:49:28 +0200
commitbc233c576d24adf640d333394228b93d548d75cc (patch)
tree8d7cbb5e9ecdb4abb671f620a7d10e07b33e65ad /tests
parentbbce2bfd10d304c4748fe246fb08fbefe686d6b9 (diff)
downloadglibmm-bc233c576d24adf640d333394228b93d548d75cc.tar.gz
tests: glibmm_value: Actually test set/get().
Diffstat (limited to 'tests')
-rw-r--r--tests/glibmm_value/main.cc72
1 files changed, 61 insertions, 11 deletions
diff --git a/tests/glibmm_value/main.cc b/tests/glibmm_value/main.cc
index 29417abb..51e645fa 100644
--- a/tests/glibmm_value/main.cc
+++ b/tests/glibmm_value/main.cc
@@ -1,29 +1,79 @@
-
#include <glibmm.h>
+#include <cassert>
struct Foo
{
- int bar;
+ int bar = 1;
};
namespace Gtk
{
-class Widget;
+
+class Widget {
+};
+
}
void
test()
{
- // custom copyable
- Glib::Value<Foo> value_foo;
+ {
+ Foo foo;
+
+ // custom copyable
+ Glib::Value<Foo> value;
+ value.init(Glib::Value<Foo>::value_type()); // TODO: Avoid this step?
+ value.set(foo);
+
+ const auto v = value.get();
+ assert(v.bar == 1);
+ }
+
+ {
+ Foo foo;
+
+ // custom pointer
+ Glib::Value<Foo*> value;
+ value.init(Glib::Value<Foo*>::value_type()); // TODO: Avoid this step?
+ value.set(&foo);
+
+ const auto v = value.get();
+ assert(v);
+ }
+
+ {
+ Foo foo;
+
+ Glib::Value<const Foo*> value;
+ value.init(Glib::Value<const Foo*>::value_type()); // TODO: Avoid this step?
+ value.set(&foo);
+
+ const auto v = value.get();
+ assert(v);
+ }
+
+ {
+ Gtk::Widget widget;
+
+ // Glib::Object pointer
+ Glib::Value<Gtk::Widget*> value;
+ value.init(Glib::Value<Gtk::Widget*>::value_type()); // TODO: Avoid this step?
+ value.set(&widget);
+
+ const auto v = value.get();
+ assert(v);
+ }
+
+ {
+ Gtk::Widget widget;
- // custom pointer
- Glib::Value<Foo*> value_foo_pointer;
- Glib::Value<const Foo*> value_foo_const_pointer;
+ Glib::Value<const Gtk::Widget*> value;
+ value.init(Glib::Value<const Gtk::Widget*>::value_type()); // TODO: Avoid this step?
+ value.set(&widget);
- // Glib::Object pointer
- Glib::Value<Gtk::Widget*> value_widget_pointer;
- Glib::Value<const Gtk::Widget*> value_widget_const_pointer;
+ const auto v = value.get();
+ assert(v);
+ }
}
// Glib::Object RefPtr<>