]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/performance/performance_binary.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // test_simple_class.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 <cstdlib> // for rand()
14 #include <cstdio> // remove
15 #include <boost/config.hpp>
16 #if defined(BOOST_NO_STDC_NAMESPACE)
23 #include "../test/test_tools.hpp"
24 #include <boost/preprocessor/stringize.hpp>
25 // #include <boost/preprocessor/cat.hpp>
26 // the following fails with (only!) gcc 3.4
27 // #include BOOST_PP_STRINGIZE(BOOST_PP_CAT(../test/,BOOST_ARCHIVE_TEST))
28 // just copy over the files from the test directory
29 #include BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST)
31 #include <boost/serialization/nvp.hpp>
32 #include <boost/serialization/binary_object.hpp>
35 friend class boost::serialization::access
;
37 // note: from an aesthetic perspective, I would much prefer to have this
38 // defined out of line. Unfortunately, this trips a bug in the VC 6.0
39 // compiler. So hold our nose and put it her to permit running of tests.
40 template<class Archive
>
41 void serialize(Archive
& ar
, const unsigned int /* file_version */){
42 ar
& boost::serialization::make_nvp(
44 boost::serialization::make_binary_object(data
, sizeof(data
))
50 bool operator==(const A
& rhs
) const;
56 data
[i
] = 0xff & std::rand();
59 bool A::operator==(const A
& rhs
) const {
62 if(data
[i
] != rhs
.data
[i
])
67 int test_main( int /* argc */, char* /* argv */[] )
69 const char * testfile
= boost::archive::tmpnam(NULL
);
70 BOOST_REQUIRE(NULL
!= testfile
);
77 test_ostream
os(testfile
, TEST_STREAM_FLAGS
);
78 test_oarchive
oa(os
, TEST_ARCHIVE_FLAGS
);
79 oa
<< BOOST_SERIALIZATION_NVP(a
);
80 // note: add a little bit on the end of the archive to detect
81 // failure of text mode binary.
82 oa
<< BOOST_SERIALIZATION_NVP(i
);
85 test_istream
is(testfile
, TEST_STREAM_FLAGS
);
86 test_iarchive
ia(is
, TEST_ARCHIVE_FLAGS
);
87 ia
>> BOOST_SERIALIZATION_NVP(a1
);
88 ia
>> BOOST_SERIALIZATION_NVP(i1
);
92 std::remove(testfile
);