From 190328b7c91cf373776db9efddb7914533475e6e Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 3 May 2004 14:00:43 +0000 Subject: [PATCH] New test. git-svn-id: https://svn.dealii.org/trunk@9140 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/block_sparse_matrix_iterator_04.cc | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 tests/bits/block_sparse_matrix_iterator_04.cc diff --git a/tests/bits/block_sparse_matrix_iterator_04.cc b/tests/bits/block_sparse_matrix_iterator_04.cc new file mode 100644 index 0000000000..bd0b49016a --- /dev/null +++ b/tests/bits/block_sparse_matrix_iterator_04.cc @@ -0,0 +1,96 @@ +//---------------------------- block_sparse_matrix_iterator_04.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2004 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- block_sparse_matrix_iterator_04.cc --------------------------- + + +// this test a failure in design of the block sparse matrix iterators: falling +// off the end of the matrix does not yield the iterator provided by the end() +// function + +#include "../tests.h" +#include +#include +#include +#include + + +void test () +{ + BlockSparsityPattern bsp (2,2); + for (unsigned int i=0; i<2; ++i) + for (unsigned int j=0; j<2; ++j) + bsp.block(i,j).reinit (1,1,1); + bsp.collect_sizes (); + bsp.compress (); + + BlockSparseMatrix m(bsp); + + // advance it to the end of the matrix + BlockSparseMatrix::const_iterator it = m.begin(); + for (unsigned int i=0; i<4; ++i) + ++it; + + deallog << it->row() << ' ' << it->index() << ' ' + << it->column() << ' ' << it->block_row() << ' ' + << it->block_column() + << std::endl; + + // now also get an end iterator + BlockSparseMatrix::const_iterator it2 = m.end(); + deallog << it2->row() << ' ' << it2->index() << ' ' + << it2->column() << ' ' << it2->block_row() << ' ' + << it2->block_column() + << std::endl; + + // make sure that the two of them match + Assert (it == it2, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("block_sparse_matrix_iterator_04.output"); + deallog.attach(logfile); + deallog.depth_console(0); + + try + { + test (); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} -- 2.39.5