]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test.
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 7 Jan 2022 07:19:54 +0000 (00:19 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 8 Jan 2022 04:38:49 +0000 (21:38 -0700)
tests/serialization/sparsity_pattern_empty.cc [new file with mode: 0644]
tests/serialization/sparsity_pattern_empty.output [new file with mode: 0644]

diff --git a/tests/serialization/sparsity_pattern_empty.cc b/tests/serialization/sparsity_pattern_empty.cc
new file mode 100644 (file)
index 0000000..1127804
--- /dev/null
@@ -0,0 +1,60 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2010 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Check serialization for SparsityPattern. This used to fail for empty
+// sparsity patterns with a segfault.
+
+#include <deal.II/lac/sparsity_pattern.h>
+
+#include "../testmatrix.h"
+#include "serialization.h"
+
+
+void
+test()
+{
+  // Try a sparsity pattern that has nonzero size, but is otherwise empty
+  const unsigned int N1 = 5;
+  SparsityPattern    sp1((N1 - 1) * (N1 - 1), (N1 - 1) * (N1 - 1), 5);
+  sp1.compress();
+
+  // Also try one that is completely empty. This is the case that was
+  // shown in the original report.
+  SparsityPattern sp2;
+
+  {
+    SparsityPattern sp3;
+    verify(sp1, sp3);
+  }
+
+  {
+    SparsityPattern sp3;
+    verify(sp2, sp3);
+  }
+}
+
+
+int
+main()
+{
+  initlog();
+  deallog << std::setprecision(3);
+
+  // Now also try with the usual harness
+  test();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/serialization/sparsity_pattern_empty.output b/tests/serialization/sparsity_pattern_empty.output
new file mode 100644 (file)
index 0000000..aa452f6
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::0 0 0 0 0 0 16 16 16 16 5 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1
+
+DEAL::0 0 0 0 0 0 0 0 0 0 0 0 0
+
+DEAL::OK

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.