]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/test/test_class_info_load.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // test_class_info_load.cpp: test implementation level trait
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 // test implementation level "object_class_info"
10 // should pass compilation and execution
15 #include <boost/archive/tmpdir.hpp>
16 #include <boost/preprocessor/stringize.hpp>
17 #include "test_tools.hpp"
19 #include <boost/static_assert.hpp>
20 #include <boost/serialization/level.hpp>
21 #include <boost/serialization/tracking.hpp>
22 #include <boost/serialization/nvp.hpp>
26 friend class boost::serialization::access
;
27 template<class Archive
>
28 void serialize(Archive
& /*ar*/, const unsigned int file_version
){
29 // class that don't save class info always have a version number of 0
30 BOOST_CHECK(file_version
== 0);
31 BOOST_STATIC_ASSERT(0 == ::boost::serialization::version
<A
>::value
);
39 BOOST_CLASS_IMPLEMENTATION(A
, ::boost::serialization::object_serializable
)
40 BOOST_CLASS_TRACKING(A
, ::boost::serialization::track_never
)
42 // second case : serialize WITH class information
45 friend class boost::serialization::access
;
46 template<class Archive
>
47 void serialize(Archive
& /*ar*/, const unsigned int file_version
){
48 // verify at execution that the version number corresponds to the saved
50 BOOST_CHECK(file_version
== 2);
58 BOOST_CLASS_IMPLEMENTATION(B
, ::boost::serialization::object_class_info
)
59 BOOST_CLASS_TRACKING(B
, ::boost::serialization::track_never
)
60 BOOST_CLASS_VERSION(B
, 4)
62 void in(const char *testfile
, A
& a
, B
& b
)
64 test_istream
is(testfile
, TEST_STREAM_FLAGS
);
65 test_iarchive
ia(is
, TEST_ARCHIVE_FLAGS
);
66 ia
>> BOOST_SERIALIZATION_NVP(a
);
67 ia
>> BOOST_SERIALIZATION_NVP(a
);
68 BOOST_CHECK(a
.count
== 2); // no tracking => redundant loads
69 ia
>> BOOST_SERIALIZATION_NVP(b
);
70 ia
>> BOOST_SERIALIZATION_NVP(b
);
71 // note: archive was saved with tracking so that is what determines
72 // whether tracking is perform on load - regardless of the latest
74 BOOST_CHECK(b
.count
== 1);
78 test_main( int /* argc */, char* /* argv */[] )
83 filename
+= boost::archive::tmpdir();
85 filename
+= BOOST_PP_STRINGIZE(testfile_
);
86 filename
+= BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST
);
87 in(filename
.c_str(), a
, b
);