From 955309a1b8fe2ad7fddf2d0b0df69ade5e7d3f5e Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 13 Jun 2011 18:01:04 +0000 Subject: [PATCH] Minor adjustment. git-svn-id: https://svn.dealii.org/trunk@23811 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/serialization/pointer_01.cc | 90 +++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/serialization/pointer_01.cc diff --git a/tests/serialization/pointer_01.cc b/tests/serialization/pointer_01.cc new file mode 100644 index 0000000000..24fc94e701 --- /dev/null +++ b/tests/serialization/pointer_01.cc @@ -0,0 +1,90 @@ +//---------------------------- pointer_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. +// +//---------------------------- pointer_01.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 + +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 + 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); + + // p2 should have been created, and should + // have been different from the address of + // p1 + Assert (p2 != 0, ExcInternalError()); + Assert (p1 != p2, ExcInternalError()); + + delete p1; + delete p2; +} + + +int main () +{ + std::ofstream logfile("pointer_01/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} -- 2.39.5