From cc9815218bca13f4532bf8672937accd493d864b Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 29 Mar 2018 15:42:29 -0600 Subject: [PATCH] Add test. --- tests/base/is_contiguous_nan.cc | 54 +++++++++++++++++++++++++++++ tests/base/is_contiguous_nan.output | 2 ++ 2 files changed, 56 insertions(+) create mode 100644 tests/base/is_contiguous_nan.cc create mode 100644 tests/base/is_contiguous_nan.output diff --git a/tests/base/is_contiguous_nan.cc b/tests/base/is_contiguous_nan.cc new file mode 100644 index 0000000000..e93dca5fc1 --- /dev/null +++ b/tests/base/is_contiguous_nan.cc @@ -0,0 +1,54 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 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. +// +// --------------------------------------------------------------------- + + +// Test that is_contiguous works correctly for arrays that contain +// signaling NaNs. In the first version of the is_contiguous() helper +// function, we compared the *objects* pointed to, as opposed to the +// *addresses* of these objects. This required (i) that these objects +// have an operator==, and (ii) that a==a for any object 'a'. The +// latter is not true if 'a' is a double that contains a +// signaling_nan(), and consequently, the is_contiguous() +// function returned false for arrays with such entries. +// +// The failure of the function to recognize that the array elements +// are contiguous led to downstream failures of make_array_view(). + +#include "../tests.h" + +#include +#include + +void test () +{ + std::vector tmp (2); + tmp[0] = numbers::signaling_nan(); + tmp[1] = numbers::signaling_nan(); + deallog << (internal::ArrayViewHelper::is_contiguous (tmp.begin(), tmp.end()) + ? + "true" + : + "false") + << std::endl; +} + + +int main() +{ + deal_II_exceptions::disable_abort_on_exception(); + initlog(); + + test(); +} diff --git a/tests/base/is_contiguous_nan.output b/tests/base/is_contiguous_nan.output new file mode 100644 index 0000000000..6064c35fc2 --- /dev/null +++ b/tests/base/is_contiguous_nan.output @@ -0,0 +1,2 @@ + +DEAL::true -- 2.39.5