Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/serialization/test/test_primitive.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.7 KB
Line 
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
20struct 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
29std::ostream & operator<<(std::ostream &os, const A & /* a */){ return os;}
30std::istream & operator>>(std::istream &is, A & /* a */){return is;}
31
32#ifndef BOOST_NO_STD_WSTREAMBUF
33std::wostream & operator<<(std::wostream &os, const A & /* a */){ return os;}
34std::wistream & operator>>(std::wistream &is, A & /* a */){return is;}
35#endif
36
37BOOST_CLASS_IMPLEMENTATION(A, boost::serialization::primitive_type)
38
39void 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
46void 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
53int
54test_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
Note: See TracBrowser for help on using the repository browser.