From 2a18f2f6a342cab4f0e8389a7e5127b1e18d56ad Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 7 Feb 2023 09:59:05 -0700 Subject: [PATCH] Add test. --- tests/base/derivative_form_initialization.cc | 60 +++++++++++++++++++ .../derivative_form_initialization.output | 5 ++ 2 files changed, 65 insertions(+) create mode 100644 tests/base/derivative_form_initialization.cc create mode 100644 tests/base/derivative_form_initialization.output diff --git a/tests/base/derivative_form_initialization.cc b/tests/base/derivative_form_initialization.cc new file mode 100644 index 0000000000..be3a40960a --- /dev/null +++ b/tests/base/derivative_form_initialization.cc @@ -0,0 +1,60 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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. +// +// --------------------------------------------------------------------- + + +// Verify that DerivativeForm can be initialized from a +// Tensor<1,dim,Tensor. We used to have a bug where the +// copy constructor offered Tensor instead, +// but that was just wrong. + +#include + +#include + +#include + +#include "../tests.h" + +template +void +test() +{ + // Choose orders and dimensions so that they are all not equal: + constexpr int order = 2; + constexpr int dim = 1; + constexpr int spacedim = 3; + + + Tensor inner; + inner[0][0] = 1; + Tensor<1, spacedim, Tensor> t; + t[0] = t[1] = t[2] = inner; + + const DerivativeForm d(t); + + deallog << "norm: " << d.norm() << std::endl; +} + +int +main() +{ + initlog(); + + deallog << "testing float" << std::endl; + test(); + + deallog << "testing double" << std::endl; + test(); +} diff --git a/tests/base/derivative_form_initialization.output b/tests/base/derivative_form_initialization.output new file mode 100644 index 0000000000..5a0d6b83f3 --- /dev/null +++ b/tests/base/derivative_form_initialization.output @@ -0,0 +1,5 @@ + +DEAL::testing float +DEAL::norm: 1.73205 +DEAL::testing double +DEAL::norm: 1.73205 -- 2.39.5