]> https://gitweb.dealii.org/ - dealii.git/commitdiff
check an invariant of class IndexSet 17763/head
authorFernando Herrera <cafeherval@gmail.com>
Wed, 9 Oct 2024 19:42:26 +0000 (13:42 -0600)
committerFernando Herrera <cafeherval@gmail.com>
Fri, 11 Oct 2024 19:12:37 +0000 (13:12 -0600)
tests/base/index_set_empty.cc [new file with mode: 0644]
tests/base/index_set_empty.output [new file with mode: 0644]

diff --git a/tests/base/index_set_empty.cc b/tests/base/index_set_empty.cc
new file mode 100644 (file)
index 0000000..29d718b
--- /dev/null
@@ -0,0 +1,79 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2009 - 2018 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+// Test the invariant that IndexSet::is_empty() is the same as
+// IndexSet::n_elements()==0.
+
+#include <deal.II/base/index_set.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+  IndexSet index_set(20);
+
+  if (index_set.is_empty() == (index_set.n_elements() == 0))
+    {
+      deallog << "OK" << std::endl;
+    }
+  else
+    {
+      deallog << "Not OK" << std::endl;
+    }
+
+  index_set.add_range(2, 4);
+  if (index_set.is_empty() == (index_set.n_elements() == 0))
+    {
+      deallog << "OK" << std::endl;
+    }
+  else
+    {
+      deallog << "Not OK" << std::endl;
+    }
+
+  index_set.add_index(6);
+  if (index_set.is_empty() == (index_set.n_elements() == 0))
+    {
+      deallog << "OK" << std::endl;
+    }
+  else
+    {
+      deallog << "Not OK" << std::endl;
+    }
+
+  index_set.pop_back();
+  index_set.pop_back();
+  index_set.pop_back();
+
+  if (index_set.is_empty() == (index_set.n_elements() == 0))
+    {
+      deallog << "OK" << std::endl;
+    }
+  else
+    {
+      deallog << "Not OK" << std::endl;
+    }
+}
+
+
+int
+main()
+{
+  initlog();
+
+  test();
+}
diff --git a/tests/base/index_set_empty.output b/tests/base/index_set_empty.output
new file mode 100644 (file)
index 0000000..5f42bb2
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::OK
+DEAL::OK
+DEAL::OK
+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.