From: Martin Kronbichler Date: Fri, 8 Jan 2016 15:51:37 +0000 (+0100) Subject: Add another test X-Git-Tag: v8.4.0-rc2~105^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ae3e99620cde52deec6347783f387f88a4bf963;p=dealii.git Add another test --- diff --git a/tests/base/aligned_vector_04.cc b/tests/base/aligned_vector_04.cc new file mode 100644 index 0000000000..8fb76b2d59 --- /dev/null +++ b/tests/base/aligned_vector_04.cc @@ -0,0 +1,80 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 1998 - 2015 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. +// +// --------------------------------------------------------------------- + + +// check that AlignedVector::fill() does correctly call the destructor and +// constructor on a complicated class + +// NOTE: The number of calls to the constructor/destructor depends on the +// actual implementation of AlignedVector. When that is changed, this test +// will typically fail even if the implementation in AlignedVector is +// otherwise correct. When adjusting the output, make sure to check this test +// with valgrind. + +#include "../tests.h" + +#include + +// make function virtual to ensure that the function table is correctly copied +class FunctionBase +{ +public: + ~FunctionBase() {} + + virtual void do_test() = 0; +}; + +class Function +{ +public: + Function () + : + size_ (2) + { + deallog << "Construct object" << std::endl; + } + + ~Function() + { + deallog << "Destruct with size " << vec.size() << std::endl; + } + + virtual void do_test() + { + vec.resize(size_++); + deallog << "Resize vector to " << vec.size() << std::endl; + } + +private: + unsigned int size_; + std::vector vec; +}; + +int main() +{ + initlog(); + AlignedVector vec; + vec.resize(2); + vec[1].do_test(); + vec[0].do_test(); + vec[0].do_test(); + vec.fill(Function()); + vec.resize(1); + vec[0].do_test(); + vec.resize(3); + vec[0].do_test(); + vec.fill(Function()); + vec[0].do_test(); +} diff --git a/tests/base/aligned_vector_04.output b/tests/base/aligned_vector_04.output new file mode 100644 index 0000000000..be5adf2852 --- /dev/null +++ b/tests/base/aligned_vector_04.output @@ -0,0 +1,22 @@ + +DEAL::Construct object +DEAL::Destruct with size 0 +DEAL::Resize vector to 2 +DEAL::Resize vector to 2 +DEAL::Resize vector to 3 +DEAL::Construct object +DEAL::Destruct with size 0 +DEAL::Construct object +DEAL::Destruct with size 0 +DEAL::Destruct with size 0 +DEAL::Resize vector to 2 +DEAL::Construct object +DEAL::Destruct with size 2 +DEAL::Destruct with size 0 +DEAL::Resize vector to 3 +DEAL::Construct object +DEAL::Destruct with size 0 +DEAL::Resize vector to 2 +DEAL::Destruct with size 0 +DEAL::Destruct with size 0 +DEAL::Destruct with size 2 diff --git a/tests/base/table_06.cc b/tests/base/table_06.cc index ca1ba8c87e..0903a34bb8 100644 --- a/tests/base/table_06.cc +++ b/tests/base/table_06.cc @@ -20,8 +20,8 @@ // NOTE: The number of calls to the constructor/destructor depends on the // actual implementation of TableBase. When that is changed, this test will -// typically fail. When adjusting the output, make sure to check this test -// with valgrind +// typically fail even if the implementation of TableBase is correct. When +// adjusting the output, make sure to check this test with valgrind. #include "../tests.h"