]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Two new tests.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 13 Jun 2011 17:56:14 +0000 (17:56 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 13 Jun 2011 17:56:14 +0000 (17:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@23810 0785d39b-7218-0410-832d-ea1e28bc413d

tests/serialization/pointer.cc [new file with mode: 0644]
tests/serialization/pointer/cmp/generic [new file with mode: 0644]
tests/serialization/test_01.cc [new file with mode: 0644]
tests/serialization/test_01/cmp/generic [new file with mode: 0644]

diff --git a/tests/serialization/pointer.cc b/tests/serialization/pointer.cc
new file mode 100644 (file)
index 0000000..9a19703
--- /dev/null
@@ -0,0 +1,81 @@
+//----------------------------  pointer.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2010, 2011 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.
+//
+//----------------------------  pointer.cc  ---------------------------
+
+// test what happens when serializing a pointer. is a new object created when
+// loading into another pointer that is NULL? this is in fact what happens
+
+#include "serialization.h"
+
+#include <typeinfo>
+
+int object_number = 1;
+
+class C
+{
+  public:
+    C ()
+      {
+       object_number = ::object_number++;
+       deallog << "Default constructor. Object number "
+               << object_number
+               << std::endl;
+      }
+
+    C (const C&)
+      {
+       object_number = ::object_number++;
+       deallog << "copy constructor. Object number "
+               << object_number
+               << std::endl;
+      }
+
+    template <typename Archive>
+    void serialize (Archive &ar, const unsigned int version)
+      {
+       deallog << "Serializing object number "
+               << object_number
+               << " via " << typeid(Archive).name()
+               << std::endl;
+      }
+
+    bool operator == (const C &) const
+      {
+       return true;
+      }
+
+  private:
+    unsigned int object_number;
+};
+
+
+void test ()
+{
+  C *p1 = new C();
+  C *p2;
+  
+  verify (p1, p2);
+}
+
+
+int main ()
+{
+  std::ofstream logfile("pointer/output");
+  deallog << std::setprecision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/serialization/pointer/cmp/generic b/tests/serialization/pointer/cmp/generic
new file mode 100644 (file)
index 0000000..6170116
--- /dev/null
@@ -0,0 +1,6 @@
+JobId unknown Mon Jun 13 12:54:54 2011
+DEAL::Default constructor. Object number 1
+DEAL::Serializing object number 1 via N5boost7archive13text_oarchiveE
+DEAL::22 serialization::archive 9 0 1 0
+0
+
diff --git a/tests/serialization/test_01.cc b/tests/serialization/test_01.cc
new file mode 100644 (file)
index 0000000..bf1cb0c
--- /dev/null
@@ -0,0 +1,79 @@
+//----------------------------  test_01.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2010, 2011 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.
+//
+//----------------------------  test_01.cc  ---------------------------
+
+// a basic test for some serialization functionality
+
+#include "serialization.h"
+
+#include <typeinfo>
+
+int object_number = 1;
+
+class C
+{
+  public:
+    C ()
+      {
+       object_number = ::object_number++;
+       deallog << "Default constructor. Object number "
+               << object_number
+               << std::endl;
+      }
+
+    C (const C&)
+      {
+       object_number = ::object_number++;
+       deallog << "copy constructor. Object number "
+               << object_number
+               << std::endl;
+      }
+
+    template <typename Archive>
+    void serialize (Archive &ar, const unsigned int version)
+      {
+       deallog << "Serializing object number "
+               << object_number
+               << " via " << typeid(Archive).name()
+               << std::endl;
+      }
+
+    bool operator == (const C &) const
+      {
+       return true;
+      }
+
+  private:
+    unsigned int object_number;
+};
+
+
+void test ()
+{
+  C p1, p2;
+  
+  verify (p1, p2);
+}
+
+
+int main ()
+{
+  std::ofstream logfile("test_01/output");
+  deallog << std::setprecision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/serialization/test_01/cmp/generic b/tests/serialization/test_01/cmp/generic
new file mode 100644 (file)
index 0000000..9260221
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL::Default constructor. Object number 1
+DEAL::Default constructor. Object number 2
+DEAL::Serializing object number 1 via N5boost7archive13text_oarchiveE
+DEAL::22 serialization::archive 9 0 0
+
+DEAL::Serializing object number 2 via N5boost7archive13text_iarchiveE
+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.