]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test. 6123/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 29 Mar 2018 21:42:29 +0000 (15:42 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 29 Mar 2018 21:42:29 +0000 (15:42 -0600)
tests/base/is_contiguous_nan.cc [new file with mode: 0644]
tests/base/is_contiguous_nan.output [new file with mode: 0644]

diff --git a/tests/base/is_contiguous_nan.cc b/tests/base/is_contiguous_nan.cc
new file mode 100644 (file)
index 0000000..e93dca5
--- /dev/null
@@ -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<double>(), 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 <deal.II/base/array_view.h>
+#include <deal.II/base/signaling_nan.h>
+
+void test ()
+{
+  std::vector<double> tmp (2);
+  tmp[0] = numbers::signaling_nan<double>();
+  tmp[1] = numbers::signaling_nan<double>();
+  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 (file)
index 0000000..6064c35
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::true

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.