]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/test/test_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
11 #include <cstddef> // NULL
12 #include <cstdio> // remove
15 #include <boost/config.hpp>
16 #if defined(BOOST_NO_STDC_NAMESPACE)
22 // the following is to ensure that when one of the libraries changes
23 // BJAM rebuilds and relinks the test.
25 #include "polymorphic_text_archive.hpp"
26 #include "polymorphic_text_warchive.hpp"
27 #include "polymorphic_binary_archive.hpp"
28 #include "polymorphic_xml_archive.hpp"
29 #include "polymorphic_xml_warchive.hpp"
32 #include "test_tools.hpp"
34 #include <boost/archive/polymorphic_oarchive.hpp>
35 #include <boost/archive/polymorphic_iarchive.hpp>
37 #include <boost/serialization/nvp.hpp>
38 #include "test_polymorphic_A.hpp"
40 int test_main(int /* argc */, char * /* argv */ [])
42 const char * testfile
= boost::archive::tmpnam(NULL
);
43 BOOST_REQUIRE(NULL
!= testfile
);
46 // test using using polymorphic interface
48 test_ostream
os(testfile
, TEST_STREAM_FLAGS
);
49 test_oarchive
oa_implementation(os
, TEST_ARCHIVE_FLAGS
);
50 boost::archive::polymorphic_oarchive
& oa_interface
= oa_implementation
;
51 oa_interface
<< BOOST_SERIALIZATION_NVP(d
);
54 test_istream
is(testfile
, TEST_STREAM_FLAGS
);
55 test_iarchive
ia_implementation(is
, TEST_ARCHIVE_FLAGS
);
56 boost::archive::polymorphic_iarchive
& ia_interface
= ia_implementation
;
57 ia_interface
>> BOOST_SERIALIZATION_NVP(d1
);
60 std::remove(testfile
);
62 // test using using polymorphic implementation.
64 test_ostream
os(testfile
, TEST_STREAM_FLAGS
);
65 test_oarchive
oa_implementation(os
, TEST_ARCHIVE_FLAGS
);
66 oa_implementation
<< BOOST_SERIALIZATION_NVP(d
);
69 test_istream
is(testfile
, TEST_STREAM_FLAGS
);
70 test_iarchive
ia_implementation(is
, TEST_ARCHIVE_FLAGS
);
71 ia_implementation
>> BOOST_SERIALIZATION_NVP(d1
);
74 std::remove(testfile
);
76 // test using using polymorphic interface.
78 test_ostream
os(testfile
, TEST_STREAM_FLAGS
);
79 boost::archive::polymorphic_oarchive
* oa_implementation
80 = new test_oarchive(os
, TEST_ARCHIVE_FLAGS
);
81 *oa_implementation
<< BOOST_SERIALIZATION_NVP(d
);
82 delete oa_implementation
;
85 test_istream
is(testfile
, TEST_STREAM_FLAGS
);
86 boost::archive::polymorphic_iarchive
* ia_implementation
87 = new test_iarchive(is
, TEST_ARCHIVE_FLAGS
);
88 *ia_implementation
>> BOOST_SERIALIZATION_NVP(d1
);
89 delete ia_implementation
;
92 std::remove(testfile
);