From: Wolfgang Bangerth Date: Sat, 27 Jun 2020 12:29:53 +0000 (-0600) Subject: Add a test. X-Git-Tag: v9.3.0-rc1~1360^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9c846c889711061f5bea1183227a13ddb53beac;p=dealii.git Add a test. --- diff --git a/tests/tensors/tensor_32.cc b/tests/tensors/tensor_32.cc new file mode 100644 index 0000000000..ba684d8e93 --- /dev/null +++ b/tests/tensors/tensor_32.cc @@ -0,0 +1,54 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2020 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.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Test that we can initialize a Tensor from ArrayView + +#include +#include + +#include "../tests.h" + + +template +void +test() +{ + const std::vector values = {1, 2, 3, 4, 5, 6, 7, 8, 9}; + + // Check for Tensor<1,dim> + deallog << Tensor<1, dim>( + make_array_view(values.begin(), values.begin() + dim)) + << std::endl; + + // Check for Tensor<2,dim> + deallog << Tensor<2, dim>( + make_array_view(values.begin(), values.begin() + dim * dim)) + << std::endl; +} + +int +main(int argc, char *argv[]) +{ + initlog(); + + test<1>(); + test<2>(); + test<3>(); + + deallog << "OK" << std::endl; + + return 0; +} diff --git a/tests/tensors/tensor_32.output b/tests/tensors/tensor_32.output new file mode 100644 index 0000000000..81470f79a5 --- /dev/null +++ b/tests/tensors/tensor_32.output @@ -0,0 +1,8 @@ + +DEAL::1.00000 +DEAL::1.00000 +DEAL::1.00000 2.00000 +DEAL::1.00000 2.00000 3.00000 4.00000 +DEAL::1.00000 2.00000 3.00000 +DEAL::1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 8.00000 9.00000 +DEAL::OK