]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New test.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Aug 2005 17:06:21 +0000 (17:06 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Aug 2005 17:06:21 +0000 (17:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@11243 0785d39b-7218-0410-832d-ea1e28bc413d

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

diff --git a/tests/bits/accessor_equality.cc b/tests/bits/accessor_equality.cc
new file mode 100644 (file)
index 0000000..031919c
--- /dev/null
@@ -0,0 +1,106 @@
+//----------------------------  accessor_equality.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005 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.
+//
+//----------------------------  accessor_equality.cc  ---------------------------
+
+// test for equality of accessor objects
+
+#include "../tests.h"
+#include <iostream>
+#include <fstream>
+
+#include <fe/fe_q.h>
+#include <dofs/dof_handler.h>
+#include <grid/tria.h>
+#include <grid/tria_iterator.h>
+#include <grid/tria_accessor.h>
+#include <dofs/dof_accessor.h>
+#include <grid/grid_generator.h>
+
+
+
+template <int dim>
+void test ()
+{
+  deallog << dim << 'd' << std::endl;
+  
+  Triangulation<dim> tria;  
+  GridGenerator::hyper_cube (tria,0,1);
+  tria.refine_global (1);
+
+  deallog << tria.begin_active() << std::endl;
+
+                                   // test a few comparison operators
+  {
+    const typename Triangulation<dim>::active_cell_iterator
+      cell = tria.begin_active();
+    Assert (cell == cell, ExcInternalError());
+    Assert (! (cell != cell), ExcInternalError());
+    Assert (! (cell < cell), ExcInternalError());
+  }
+
+                                   // same with non-active iterators
+  {
+    const typename Triangulation<dim>::cell_iterator
+      cell = tria.begin();
+    Assert (cell == cell, ExcInternalError());
+    Assert (! (cell != cell), ExcInternalError());
+    Assert (! (cell < cell), ExcInternalError());
+  }
+  
+  FE_Q<dim> fe (1);
+  DoFHandler<dim> dof_handler (tria);
+  dof_handler.distribute_dofs (fe);
+
+                                   // now do the same tests with the
+                                   // DoFHandler iterators
+  {
+    const typename DoFHandler<dim>::active_cell_iterator
+      cell = dof_handler.begin_active();
+    Assert (cell == cell, ExcInternalError());
+    Assert (! (cell != cell), ExcInternalError());
+    Assert (! (cell < cell), ExcInternalError());
+  }
+  {
+    const typename DoFHandler<dim>::cell_iterator
+      cell = dof_handler.begin();
+    Assert (cell == cell, ExcInternalError());
+    Assert (! (cell != cell), ExcInternalError());
+    Assert (! (cell < cell), ExcInternalError());
+  }
+
+                                   // finally check that two iterators
+                                   // pointing into different DoFHandlers
+                                   // can't be the same
+                                   //
+                                   // this test accidentally failed before a
+                                   // fix was checked in on 2005-08-08 that
+                                   // completely forbids comparing iterators
+                                   // into different DoFHandlers at all
+  {
+    DoFHandler<dim> dof_handler2 (tria);
+    dof_handler2.distribute_dofs (fe);
+    Assert (dof_handler.begin_active() != dof_handler2.begin_active(),
+            ExcInternalError());
+  }
+}
+
+
+int main ()
+{
+  std::ofstream logfile("accessor_equality.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test<1> ();
+  test<2> ();
+  test<3> ();
+}

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.