diff options
author | Murray Cumming <murrayc@murrayc.com> | 2017-03-17 10:36:23 +0100 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2017-03-17 10:44:21 +0100 |
commit | c5fff7f4a03d2ca97ba7269e0d5145f22422ff9a (patch) | |
tree | f5d0f44f56af2a668a2c7d0803bc0144c05887cc /tests | |
parent | d9c9b2dbe4742388e621cf084908c212d7923fc4 (diff) | |
download | glibmm-c5fff7f4a03d2ca97ba7269e0d5145f22422ff9a.tar.gz |
Replace remaining uses of Glib::ArrayHandle<> with std::vector.
Using Glib::ArrayHandler<>::vector_to_array() and
Glib::ArrayHandler<>::array_to_vector() instead, and only in the
implementatoin instead of in the API.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 5 | ||||
-rw-r--r-- | tests/glibmm_bool_arrayhandle/main.cc | 97 | ||||
-rw-r--r-- | tests/glibmm_null_containerhandle/main.cc | 43 |
3 files changed, 0 insertions, 145 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 4a0d2fe5..a3d7803b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,9 +42,7 @@ check_PROGRAMS = \ glibmm_variant/test \ glibmm_vector/test \ glibmm_bool_vector/test \ - glibmm_bool_arrayhandle/test \ glibmm_null_vectorutils/test \ - glibmm_null_containerhandle/test \ glibmm_refptr/test \ glibmm_refptr_sigc_bind/test \ glibmm_weakref/test \ @@ -114,11 +112,8 @@ glibmm_variant_test_SOURCES = glibmm_variant/main.cc glibmm_vector_test_SOURCES = glibmm_vector/main.cc glibmm_vector_test_LDADD = $(giomm_ldadd) glibmm_bool_vector_test_SOURCES = glibmm_bool_vector/main.cc -glibmm_bool_arrayhandle_test_SOURCES = glibmm_bool_arrayhandle/main.cc glibmm_null_vectorutils_test_SOURCES = glibmm_null_vectorutils/main.cc glibmm_null_vectorutils_test_LDADD = $(giomm_ldadd) -glibmm_null_containerhandle_test_SOURCES = glibmm_null_containerhandle/main.cc -glibmm_null_containerhandle_test_LDADD = $(giomm_ldadd) glibmm_refptr_test_SOURCES = glibmm_refptr/main.cc glibmm_refptr_sigc_bind_test_SOURCES = glibmm_refptr_sigc_bind/main.cc glibmm_weakref_test_SOURCES = glibmm_weakref/main.cc diff --git a/tests/glibmm_bool_arrayhandle/main.cc b/tests/glibmm_bool_arrayhandle/main.cc deleted file mode 100644 index 788559e9..00000000 --- a/tests/glibmm_bool_arrayhandle/main.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (C) 2011 The glibmm Development Team - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include <cstdlib> -#include <ctime> - -#include <iostream> - -#include <glibmm.h> - -// Use this line if you want debug output: -// std::ostream& ostr = std::cout; - -// This seems nicer and more useful than putting an ifdef around the use of std::cout: -std::stringstream debug; -std::ostream& ostr = debug; - -const unsigned int magic_limit(5); - -void -setup_rand() -{ - static bool setup(false); - - if (!setup) - { - std::srand(std::time(nullptr)); - setup = true; - } -} - -gboolean* -c_get_bool_array() -{ - gboolean* array(static_cast<gboolean*>(g_malloc((magic_limit + 1) * sizeof(gboolean)))); - - setup_rand(); - for (unsigned int iter(0); iter < magic_limit; ++iter) - { - array[iter] = std::rand() % 2 ? TRUE : FALSE; - } - array[magic_limit] = FALSE; - return array; -} - -void -c_print_bool_array(gboolean* array) -{ - for (unsigned int iter(0); iter < magic_limit; ++iter) - { - ostr << iter << ": " << (array[iter] ? "TRUE" : "FALSE") << "\n"; - } -} - -Glib::ArrayHandle<bool> -cxx_get_bool_array() -{ - return Glib::ArrayHandle<bool>(c_get_bool_array(), magic_limit, Glib::OWNERSHIP_SHALLOW); -} - -void -cxx_print_bool_array(const Glib::ArrayHandle<bool>& array) -{ - c_print_bool_array(const_cast<gboolean*>(array.data())); -} - -int -main() -{ - Glib::init(); - - std::vector<bool> v(cxx_get_bool_array()); - std::list<bool> l(cxx_get_bool_array()); - std::deque<bool> d(cxx_get_bool_array()); - - ostr << "vector:\n"; - cxx_print_bool_array(v); - ostr << "list:\n"; - cxx_print_bool_array(l); - ostr << "deque:\n"; - cxx_print_bool_array(d); - - return EXIT_SUCCESS; -} diff --git a/tests/glibmm_null_containerhandle/main.cc b/tests/glibmm_null_containerhandle/main.cc deleted file mode 100644 index 80d83506..00000000 --- a/tests/glibmm_null_containerhandle/main.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2011 The gtkmm Development Team - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <glibmm/arrayhandle.h> -#include <glibmm/listhandle.h> -#include <glibmm/slisthandle.h> - -#include <giomm/credentials.h> -#include <giomm/init.h> - -int -main() -{ - Gio::init(); - using CrePtr = Glib::RefPtr<Gio::Credentials>; - - std::vector<CrePtr> v1(Glib::ArrayHandle<CrePtr>(nullptr, Glib::OWNERSHIP_DEEP)); - std::vector<CrePtr> v2(Glib::ArrayHandle<CrePtr>(nullptr, 5, Glib::OWNERSHIP_DEEP)); - std::vector<CrePtr> v3(Glib::ListHandle<CrePtr>(nullptr, Glib::OWNERSHIP_DEEP)); - std::vector<CrePtr> v4(Glib::SListHandle<CrePtr>(nullptr, Glib::OWNERSHIP_DEEP)); - std::vector<bool> v5(Glib::ArrayHandle<bool>(nullptr, Glib::OWNERSHIP_DEEP)); - std::vector<bool> v6(Glib::ArrayHandle<bool>(nullptr, 5, Glib::OWNERSHIP_DEEP)); - - if (v1.empty() && v2.empty() && v3.empty() && v4.empty() && v5.empty() && v6.empty()) - { - return 0; - } - return 1; -} |