]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add a test 11743/head
authorMatthias Maier <tamiko@43-1.org>
Sat, 20 Feb 2021 01:13:44 +0000 (19:13 -0600)
committerMatthias Maier <tamiko@43-1.org>
Sat, 20 Feb 2021 01:13:44 +0000 (19:13 -0600)
tests/base/ndarray.cc [new file with mode: 0644]
tests/base/ndarray.output [new file with mode: 0644]

diff --git a/tests/base/ndarray.cc b/tests/base/ndarray.cc
new file mode 100644 (file)
index 0000000..be4d074
--- /dev/null
@@ -0,0 +1,54 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2021 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.
+//
+// ---------------------------------------------------------------------
+
+
+// test that the ndarray type alias does what it promises to do.
+
+#include <deal.II/base/ndarray.h>
+
+#include <type_traits>
+
+#include "../tests.h"
+
+int
+main()
+{
+  initlog();
+
+  dealii::ndarray<double>             r0;
+  dealii::ndarray<double, 1>          r1;
+  dealii::ndarray<double, 1, 2>       r2;
+  dealii::ndarray<double, 1, 2, 3>    r3;
+  dealii::ndarray<double, 1, 2, 3, 4> r4;
+
+  static_assert(std::is_same<decltype(r0), double>::value,
+                "types must be the same");
+  static_assert(std::is_same<decltype(r1), std::array<double, 1>>::value,
+                "types must be the same");
+  static_assert(
+    std::is_same<decltype(r2), std::array<std::array<double, 2>, 1>>::value,
+    "types must be the same");
+  static_assert(
+    std::is_same<decltype(r3),
+                 std::array<std::array<std::array<double, 3>, 2>, 1>>::value,
+    "types must be the same");
+  static_assert(
+    std::is_same<decltype(r4),
+                 std::array<std::array<std::array<std::array<double, 4>, 3>, 2>,
+                            1>>::value,
+    "types must be the same");
+
+  return 0;
+}
diff --git a/tests/base/ndarray.output b/tests/base/ndarray.output
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+

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.