[glibmm] tests: glibmm_value: Actually test set/get().



commit bc233c576d24adf640d333394228b93d548d75cc
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Apr 7 21:49:28 2017 +0200

    tests: glibmm_value: Actually test set/get().

 tests/glibmm_value/main.cc |   72 +++++++++++++++++++++++++++++++++++++-------
 1 files changed, 61 insertions(+), 11 deletions(-)
---
diff --git a/tests/glibmm_value/main.cc b/tests/glibmm_value/main.cc
index 29417ab..51e645f 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<>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]