]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New test.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 3 May 2004 14:00:43 +0000 (14:00 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 3 May 2004 14:00:43 +0000 (14:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@9140 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/block_sparse_matrix_iterator_04.cc [new file with mode: 0644]

diff --git a/tests/bits/block_sparse_matrix_iterator_04.cc b/tests/bits/block_sparse_matrix_iterator_04.cc
new file mode 100644 (file)
index 0000000..bd0b490
--- /dev/null
@@ -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 <lac/block_sparsity_pattern.h>
+#include <lac/block_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+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<double> m(bsp);
+
+                                   // advance it to the end of the matrix
+  BlockSparseMatrix<double>::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<double>::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;
+    };
+}

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.