]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test. 3826/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Sat, 21 Jan 2017 15:50:45 +0000 (08:50 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 21 Jan 2017 15:51:31 +0000 (08:51 -0700)
tests/trilinos/vector_reference_01.cc [new file with mode: 0644]
tests/trilinos/vector_reference_01.output [new file with mode: 0644]

diff --git a/tests/trilinos/vector_reference_01.cc b/tests/trilinos/vector_reference_01.cc
new file mode 100644 (file)
index 0000000..79d7a51
--- /dev/null
@@ -0,0 +1,95 @@
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// TrilinosWrappers::internal::VectorReference had its non-const copy
+// operator return a const reference. that was non-intuitive but,
+// because of the particular semantics of copying vector reference
+// objects, made no difference. either way, have a check for these
+// semantics
+
+#include "../tests.h"
+#include <deal.II/base/utilities.h>
+#include <deal.II/lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+  TrilinosWrappers::Vector v(3);
+  v(0) = 0;
+  v(1) = 1;
+  v(2) = 2;
+
+  TrilinosWrappers::internal::VectorReference a (v(0));
+  TrilinosWrappers::internal::VectorReference b (v(1));
+  TrilinosWrappers::internal::VectorReference c (v(2));
+
+  // copy VectorReference objects. note that operator= for these
+  // objects does not copy the*content* of the reference object, but
+  // assigns the value of the vector element referenced on the right
+  // to the vector element referenced on the left
+  (c = a) = b;
+  b = a;
+
+  deallog << static_cast<TrilinosScalar>(a) << std::endl; // should point to v(0)
+  deallog << static_cast<TrilinosScalar>(b) << std::endl; // should point to v(0)
+  deallog << static_cast<TrilinosScalar>(c) << std::endl; // should point to v(0)
+}
+
+
+
+int main (int argc,char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.threshold_double(1.e-10);
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, testing_max_num_threads());
+
+
+  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;
+    };
+}
diff --git a/tests/trilinos/vector_reference_01.output b/tests/trilinos/vector_reference_01.output
new file mode 100644 (file)
index 0000000..c1bad75
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::0
+DEAL::0
+DEAL::1.00000

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.