]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New test.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 29 Feb 2004 20:52:15 +0000 (20:52 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 29 Feb 2004 20:52:15 +0000 (20:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@8621 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/vector_57.cc [new file with mode: 0644]

diff --git a/tests/bits/vector_57.cc b/tests/bits/vector_57.cc
new file mode 100644 (file)
index 0000000..821ecde
--- /dev/null
@@ -0,0 +1,86 @@
+//----------------------------  vector_57.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  vector_57.cc  ---------------------------
+
+
+// check Vector::is_non_zero
+
+#include "../tests.h"
+#include <lac/vector.h>    
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+                                   // set only certain elements of the
+                                   // vector. they are all positive
+  std::vector<bool> pattern (v.size(), false);
+  for (unsigned int i=0; i<v.size(); i+=1+i)
+    {
+      v(i) += i;
+      pattern[i] = true;
+    }
+
+  v.compress ();
+
+                                   // check that the vector is really
+                                   // non-negative
+  Assert (v.is_non_negative() == true, ExcInternalError());
+
+                                   // then set a single element to a negative
+                                   // value and check again
+  v(v.size()/2) = -1;
+  Assert (v.is_non_negative() == false, ExcInternalError());  
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("vector_57.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      Vector<double> v (100);
+      test (v);
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 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.