From f9c846c889711061f5bea1183227a13ddb53beac Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sat, 27 Jun 2020 06:29:53 -0600 Subject: [PATCH] Add a test. --- tests/tensors/tensor_32.cc | 54 ++++++++++++++++++++++++++++++++++ tests/tensors/tensor_32.output | 8 +++++ 2 files changed, 62 insertions(+) create mode 100644 tests/tensors/tensor_32.cc create mode 100644 tests/tensors/tensor_32.output 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 -- 2.39.5