From 4ad708038d739f30ba8452d7a615ee7c21dc98a1 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 6 Feb 2017 17:50:21 +0100 Subject: [PATCH] Add test for copying FilteredOperator --- include/deal.II/grid/filtered_iterator.h | 5 +++ tests/grid/filtered_iterator_05.cc | 50 ++++++++++++++++++++++++ tests/grid/filtered_iterator_05.output | 2 + 3 files changed, 57 insertions(+) create mode 100644 tests/grid/filtered_iterator_05.cc create mode 100644 tests/grid/filtered_iterator_05.output diff --git a/include/deal.II/grid/filtered_iterator.h b/include/deal.II/grid/filtered_iterator.h index 22d6dff9aa..6aea724cb2 100644 --- a/include/deal.II/grid/filtered_iterator.h +++ b/include/deal.II/grid/filtered_iterator.h @@ -960,6 +960,11 @@ FilteredIterator & FilteredIterator:: operator = (const FilteredIterator &fi) { + // Using equivalent code to the one for 'operator=(const BaseIterator &bi)' + // below, some compiler would not cast fi to the base class of type + // BaseIterator but try to go through constructing a new Accessor from fi + // which fails. Hence, we just use an explicit upcast and call the above- + // mentioned method. const BaseIterator &bi = fi; return operator = (bi); } diff --git a/tests/grid/filtered_iterator_05.cc b/tests/grid/filtered_iterator_05.cc new file mode 100644 index 0000000000..ed5a04dc81 --- /dev/null +++ b/tests/grid/filtered_iterator_05.cc @@ -0,0 +1,50 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, 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. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +/* + * Test that copying a FilteredIterator works + */ + +#include +#include +#include +#include +#include +#include "../tests.h" + +template +void +test() +{ + Triangulation triangulation; + DoFHandler dof_handler(triangulation); + GridGenerator::hyper_cube(triangulation); + + FilteredIterator::level_cell_iterator> begin + (IteratorFilters::LocallyOwnedLevelCell(), dof_handler.begin()); + FilteredIterator::level_cell_iterator> end + (IteratorFilters::LocallyOwnedLevelCell(), dof_handler.end()); + end = begin; + + deallog << "OK" << std::endl; +} + +int main() +{ + initlog(); + test<2>(); + + return 0; +} diff --git a/tests/grid/filtered_iterator_05.output b/tests/grid/filtered_iterator_05.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/grid/filtered_iterator_05.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5