]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/performance/performance_polymorphic.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // test_polymorphic.cpp
4 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5 // Use, modification and distribution is subject to the Boost Software
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 // should pass compilation and execution
13 #include <cstdio> // remove
14 #include <boost/config.hpp>
15 #if defined(BOOST_NO_STDC_NAMESPACE)
21 #include "../test/test_tools.hpp"
23 #if !defined(BOOST_ARCHIVE_TEST)
24 #define BOOST_ARCHIVE_TEST polymorphic_text_archive.hpp
27 // the following is to ensure that when one of the libraries changes
28 // BJAM rebuilds and relinks the test.
30 #include "polymorphic_text_archive.hpp"
31 #include "polymorphic_text_warchive.hpp"
32 #include "polymorphic_binary_archive.hpp"
33 #include "polymorphic_xml_archive.hpp"
34 #include "polymorphic_xml_warchive.hpp"
37 #include <boost/preprocessor/stringize.hpp>
38 // #include <boost/preprocessor/cat.hpp>
39 // the following fails with (only!) gcc 3.4
40 // #include BOOST_PP_STRINGIZE(BOOST_PP_CAT(../test/,BOOST_ARCHIVE_TEST))
41 // just copy over the files from the test directory
42 #include BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST)
44 #include <boost/archive/polymorphic_oarchive.hpp>
45 #include <boost/archive/polymorphic_iarchive.hpp>
47 #include <boost/serialization/nvp.hpp>
48 #include "../test/test_polymorphic_A.hpp"
50 int test_main(int /* argc */, char * /* argv */ [])
52 const char * testfile
= boost::archive::tmpnam(NULL
);
53 BOOST_REQUIRE(NULL
!= testfile
);
56 // test using using polymorphic interface
58 test_ostream
os(testfile
, TEST_STREAM_FLAGS
);
59 test_oarchive
oa_implementation(os
);
60 boost::archive::polymorphic_oarchive
& oa_interface
= oa_implementation
;
61 oa_interface
<< BOOST_SERIALIZATION_NVP(d
);
64 test_istream
is(testfile
, TEST_STREAM_FLAGS
);
65 test_iarchive
ia_implementation(is
);
66 boost::archive::polymorphic_iarchive
& ia_interface
= ia_implementation
;
67 ia_interface
>> BOOST_SERIALIZATION_NVP(d1
);
70 std::remove(testfile
);
72 // test using using polymorphic implementation.
74 test_ostream
os(testfile
, TEST_STREAM_FLAGS
);
75 test_oarchive
oa_implementation(os
);
76 oa_implementation
<< BOOST_SERIALIZATION_NVP(d
);
79 test_istream
is(testfile
, TEST_STREAM_FLAGS
);
80 test_iarchive
ia_implementation(is
);
81 ia_implementation
>> BOOST_SERIALIZATION_NVP(d1
);
84 std::remove(testfile
);
86 // test using using polymorphic implementation.
88 test_ostream
os(testfile
, TEST_STREAM_FLAGS
);
89 boost::archive::polymorphic_oarchive
* oa_implementation
90 = new test_oarchive(os
);
91 *oa_implementation
<< BOOST_SERIALIZATION_NVP(d
);
92 delete oa_implementation
;
95 test_istream
is(testfile
, TEST_STREAM_FLAGS
);
96 boost::archive::polymorphic_iarchive
* ia_implementation
97 = new test_iarchive(is
);
98 *ia_implementation
>> BOOST_SERIALIZATION_NVP(d1
);
99 delete ia_implementation
;
101 BOOST_CHECK(d
== d1
);
102 std::remove(testfile
);