From: Wolfgang Bangerth Date: Thu, 29 Mar 2018 21:42:29 +0000 (-0600) Subject: Add test. X-Git-Tag: v9.0.0-rc1~265^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6123%2Fhead;p=dealii.git Add test. --- 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