From bc15793cbfd9992267417eec812a8bc7635f7fbb Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Tue, 3 Feb 2015 15:01:06 +0100 Subject: [PATCH] added a failing test --- tests/base/tensor_nondefault_constructor.cc | 72 +++++++++++++++++++ .../base/tensor_nondefault_constructor.output | 1 + 2 files changed, 73 insertions(+) create mode 100644 tests/base/tensor_nondefault_constructor.cc create mode 100644 tests/base/tensor_nondefault_constructor.output diff --git a/tests/base/tensor_nondefault_constructor.cc b/tests/base/tensor_nondefault_constructor.cc new file mode 100644 index 0000000000..6357f575c8 --- /dev/null +++ b/tests/base/tensor_nondefault_constructor.cc @@ -0,0 +1,72 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 1998 - 2014 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. +// +// --------------------------------------------------------------------- + + +// Same as tensor.cc, but uses tensors based on floats instead of doubles + +#include "../tests.h" +#include +#include +#include +#include +#include + +int main () +{ + std::ofstream logfile("output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + float a[3][3] = {{1, 2, 3}, {3, 4, 5}, {6, 7, 8}}; + float b[3] = {25,31,37}; + + const unsigned int dim=3; + + // rank 2 + { + Tensor<2,dim,float> t(a); + Tensor<2,dim,double> dt(t), dt2; + dt2 = t; + Assert (dt2 == dt, ExcInternalError()); + + Tensor<2,dim,float> ft(dt), ft2; + ft2 = dt; + Assert (ft2 == ft, ExcInternalError()); + + Tensor<2,dim,std::complex > ct(dt), ct2; + ct2 = dt; + Assert (ct2 == ct, ExcInternalError()); + } + + // rank 1 + { + Tensor<1,dim,float> t(b); + Tensor<1,dim,double> dt(t), dt2; + dt2 = t; + Assert (dt2 == dt, ExcInternalError()); + + Tensor<1,dim,float> ft(dt),ft2; + ft2 = dt; + Assert (ft2 == ft, ExcInternalError()); + + Tensor<1,dim,std::complex> ct(dt), ct2; + ct2 = dt; + Assert (ct2 == ct, ExcInternalError()); + } + + deallog << "OK." << std::endl; +} diff --git a/tests/base/tensor_nondefault_constructor.output b/tests/base/tensor_nondefault_constructor.output new file mode 100644 index 0000000000..6b3ab10675 --- /dev/null +++ b/tests/base/tensor_nondefault_constructor.output @@ -0,0 +1 @@ +DEAL::OK. -- 2.39.5