[gtkmm] tests: tree_model_iterator: Add simple test of constness issues.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] tests: tree_model_iterator: Add simple test of constness issues.
- Date: Wed, 15 Mar 2017 08:15:24 +0000 (UTC)
commit a3d0b496d547d229f52828eede871729129eb31d
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Mar 15 09:12:39 2017 +0100
tests: tree_model_iterator: Add simple test of constness issues.
Bug #134520
tests/Makefile.am | 2 +
tests/tree_model_iterator/main.cc | 43 +++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 53301ea..b6211f9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -31,6 +31,7 @@ check_PROGRAMS = \
property_notification/test \
refcount_dialog/test \
scrolledwindow/test \
+ tree_model_iterator/test \
wrap_existing/test
TESTS = object_move/test \
@@ -51,6 +52,7 @@ object_move_test_SOURCES = object_move/main.cc
property_notification_test_SOURCES = property_notification/main.cc
refcount_dialog_test_SOURCES = refcount_dialog/main.cc
scrolledwindow_test_SOURCES = scrolledwindow/main.cc
+tree_model_iterator_test_SOURCES = tree_model_iterator/main.cc
wrap_existing_test_SOURCES = wrap_existing/main.cc
gdkmm_includes = -I$(top_builddir)/gdk $(if $(srcdir:.=),-I$(top_srcdir)/gdk)
diff --git a/tests/tree_model_iterator/main.cc b/tests/tree_model_iterator/main.cc
new file mode 100644
index 0000000..dd63173
--- /dev/null
+++ b/tests/tree_model_iterator/main.cc
@@ -0,0 +1,43 @@
+#include <gtkmm.h>
+#include <iostream>
+#include <cassert>
+#include <cstdlib>
+
+static void
+test_const_conversion() {
+ Gtk::TreeModel::iterator non_const_iter;
+ Gtk::TreeModel::const_iterator const_iter;
+ assert(non_const_iter == const_iter);
+ assert(const_iter == non_const_iter);
+}
+
+static void
+test_assignment_from_const() {
+ Gtk::TreeModel::iterator non_const_iter;
+ Gtk::TreeModel::const_iterator const_iter = non_const_iter;
+ assert(const_iter == non_const_iter);
+}
+
+// TODO: Find some way to check that the opposite is not possible.
+// For instance, check that the code won't compile if we try to assign
+// a const iterator to a non-const iterator.
+/*
+static void
+test_assignment_to_const() {
+ Gtk::TreeModel::const_iterator const_iter;
+ // This should not compile:
+ Gtk::TreeModel::iterator non_const_iter = const_iter;
+ assert(const_iter == non_const_iter);
+}
+*/
+
+int main(int /* argc */, char** /* argv */)
+{
+ gtk_init();
+ Gtk::Main::init_gtkmm_internals();
+
+ test_const_conversion();
+ test_assignment_from_const();
+
+ return EXIT_SUCCESS;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]