From: Wolfgang Bangerth Date: Sat, 21 Jan 2017 15:50:45 +0000 (-0700) Subject: Add test. X-Git-Tag: v8.5.0-rc1~218^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3826%2Fhead;p=dealii.git Add test. --- diff --git a/tests/trilinos/vector_reference_01.cc b/tests/trilinos/vector_reference_01.cc new file mode 100644 index 0000000000..79d7a51f2f --- /dev/null +++ b/tests/trilinos/vector_reference_01.cc @@ -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 +#include +#include +#include + + +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(a) << std::endl; // should point to v(0) + deallog << static_cast(b) << std::endl; // should point to v(0) + deallog << static_cast(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 index 0000000000..c1bad75d2c --- /dev/null +++ b/tests/trilinos/vector_reference_01.output @@ -0,0 +1,4 @@ + +DEAL::0 +DEAL::0 +DEAL::1.00000