1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
---|
2 | // test_primitive.cpp |
---|
3 | |
---|
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) |
---|
8 | |
---|
9 | // test implementation level "primitive_type" |
---|
10 | |
---|
11 | #include <fstream> |
---|
12 | |
---|
13 | #include "test_tools.hpp" |
---|
14 | #include <boost/preprocessor/stringize.hpp> |
---|
15 | #include BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST) |
---|
16 | |
---|
17 | #include <boost/serialization/level.hpp> |
---|
18 | #include <boost/serialization/nvp.hpp> |
---|
19 | |
---|
20 | struct A |
---|
21 | { |
---|
22 | template<class Archive> |
---|
23 | void serialize(Archive &ar, const unsigned int /* file_version */){ |
---|
24 | // note: should never fail here |
---|
25 | BOOST_STATIC_ASSERT(0 == sizeof(Archive)); |
---|
26 | } |
---|
27 | }; |
---|
28 | |
---|
29 | std::ostream & operator<<(std::ostream &os, const A & /* a */){ return os;} |
---|
30 | std::istream & operator>>(std::istream &is, A & /* a */){return is;} |
---|
31 | |
---|
32 | #ifndef BOOST_NO_STD_WSTREAMBUF |
---|
33 | std::wostream & operator<<(std::wostream &os, const A & /* a */){ return os;} |
---|
34 | std::wistream & operator>>(std::wistream &is, A & /* a */){return is;} |
---|
35 | #endif |
---|
36 | |
---|
37 | BOOST_CLASS_IMPLEMENTATION(A, boost::serialization::primitive_type) |
---|
38 | |
---|
39 | void out(const char *testfile, A & a) |
---|
40 | { |
---|
41 | test_ostream os(testfile, TEST_STREAM_FLAGS); |
---|
42 | test_oarchive oa(os); |
---|
43 | oa << BOOST_SERIALIZATION_NVP(a); |
---|
44 | } |
---|
45 | |
---|
46 | void in(const char *testfile, A & a) |
---|
47 | { |
---|
48 | test_istream is(testfile, TEST_STREAM_FLAGS); |
---|
49 | test_iarchive ia(is); |
---|
50 | ia >> BOOST_SERIALIZATION_NVP(a); |
---|
51 | } |
---|
52 | |
---|
53 | int |
---|
54 | test_main( int /* argc */, char* /* argv */[] ) |
---|
55 | { |
---|
56 | const char * testfile = boost::archive::tmpnam(NULL); |
---|
57 | BOOST_REQUIRE(NULL != testfile); |
---|
58 | |
---|
59 | A a; |
---|
60 | out(testfile, a); |
---|
61 | in(testfile, a); |
---|
62 | return EXIT_SUCCESS; |
---|
63 | } |
---|
64 | |
---|
65 | // EOF |
---|