]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Rename one test. Create another.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 13 Jun 2011 18:06:08 +0000 (18:06 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 13 Jun 2011 18:06:08 +0000 (18:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@23812 0785d39b-7218-0410-832d-ea1e28bc413d

tests/serialization/pointer_01/cmp/generic [moved from tests/serialization/pointer/cmp/generic with 55% similarity]
tests/serialization/pointer_02.cc [moved from tests/serialization/pointer.cc with 55% similarity]
tests/serialization/pointer_02/cmp/generic [new file with mode: 0644]

similarity index 55%
rename from tests/serialization/pointer/cmp/generic
rename to tests/serialization/pointer_01/cmp/generic
index 6170116d665602983f09aa08b80f3acf7beafc7c..bd245666b26c2d45d9ec7628b62204a67ea81387 100644 (file)
@@ -1,6 +1,9 @@
-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
 
+DEAL::Default constructor. Object number 2
+DEAL::Serializing object number 2 via N5boost7archive13text_iarchiveE
+DEAL::OK
similarity index 55%
rename from tests/serialization/pointer.cc
rename to tests/serialization/pointer_02.cc
index 9a1970334122d901057db1a5ceb674bd7e6c304a..830a9d15e784b58d688962d14678422472748b99 100644 (file)
@@ -1,4 +1,4 @@
-//----------------------------  pointer.cc  ---------------------------
+//----------------------------  pointer_02.cc  ---------------------------
 //    $Id$
 //    Version: $Name$
 //
@@ -9,16 +9,21 @@
 //    to the file deal.II/doc/license.html for the  text  and
 //    further information on this license.
 //
-//----------------------------  pointer.cc  ---------------------------
+//----------------------------  pointer_02.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
+// loading into another pointer that is non-NULL and the old pointer
+// destroyed? Or is the old object pointed to being co-opted? the former is in
+// fact what happens, and to make things just ever so slightly more awkward,
+// the previous object pointed to isn't freed but is left dangling, creating
+// the potential for a memory leak
 
 #include "serialization.h"
 
 #include <typeinfo>
 
 int object_number = 1;
+int objects_destroyed = 0;
 
 class C
 {
@@ -39,6 +44,14 @@ class C
                << std::endl;
       }
 
+    ~C ()
+      {
+       deallog << "destructor. Object number "
+               << object_number
+               << std::endl;
+       ++objects_destroyed;
+      }
+    
     template <typename Archive>
     void serialize (Archive &ar, const unsigned int version)
       {
@@ -60,16 +73,29 @@ class C
 
 void test ()
 {
-  C *p1 = new C();
-  C *p2;
+  {
+    C *p1 = new C();
+    C *p2 = new C();
   
-  verify (p1, p2);
+    verify (p1, p2);
+
+    Assert (p1 != p2, ExcInternalError());
+
+    delete p1;
+    delete p2;
+  }
+
+                                  // as mentioned above, p2 is overwritten by
+                                  // a pointer to a new object, leaving the
+                                  // original object pointed to as a memory
+                                  // leak. assert that this behavior persists
+  Assert (objects_destroyed == 2, ExcInternalError());
 }
 
 
 int main ()
 {
-  std::ofstream logfile("pointer/output");
+  std::ofstream logfile("pointer_02/output");
   deallog << std::setprecision(3);
   deallog.attach(logfile);
   deallog.depth_console(0);
diff --git a/tests/serialization/pointer_02/cmp/generic b/tests/serialization/pointer_02/cmp/generic
new file mode 100644 (file)
index 0000000..0077e32
--- /dev/null
@@ -0,0 +1,12 @@
+
+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 1 0
+0
+
+DEAL::Default constructor. Object number 3
+DEAL::Serializing object number 3 via N5boost7archive13text_iarchiveE
+DEAL::destructor. Object number 1
+DEAL::destructor. Object number 3
+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.