[29] | 1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
---|
| 2 | // test_list.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 | // should pass compilation and execution |
---|
| 10 | |
---|
| 11 | #include <fstream> |
---|
| 12 | |
---|
| 13 | #include <cstdio> // remove |
---|
| 14 | #include <boost/config.hpp> |
---|
| 15 | #if defined(BOOST_NO_STDC_NAMESPACE) |
---|
| 16 | namespace std{ |
---|
| 17 | using ::remove; |
---|
| 18 | } |
---|
| 19 | #endif |
---|
| 20 | |
---|
| 21 | #include <boost/archive/archive_exception.hpp> |
---|
| 22 | #include "test_tools.hpp" |
---|
| 23 | #include <boost/preprocessor/stringize.hpp> |
---|
| 24 | #include BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST) |
---|
| 25 | |
---|
| 26 | #include <boost/serialization/list.hpp> |
---|
| 27 | #ifdef BOOST_HAS_SLIST |
---|
| 28 | #include <boost/serialization/slist.hpp> |
---|
| 29 | #endif |
---|
| 30 | |
---|
| 31 | #include "A.hpp" |
---|
| 32 | |
---|
| 33 | int test_main( int /* argc */, char* /* argv */[] ) |
---|
| 34 | { |
---|
| 35 | const char * testfile = boost::archive::tmpnam(NULL); |
---|
| 36 | BOOST_REQUIRE(NULL != testfile); |
---|
| 37 | |
---|
| 38 | std::list<A> alist; |
---|
| 39 | alist.push_back(A()); |
---|
| 40 | alist.push_back(A()); |
---|
| 41 | { |
---|
| 42 | test_ostream os(testfile, TEST_STREAM_FLAGS); |
---|
| 43 | test_oarchive oa(os); |
---|
| 44 | oa << boost::serialization::make_nvp("alist",alist); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | std::list<A> alist1; |
---|
| 48 | { |
---|
| 49 | test_istream is(testfile, TEST_STREAM_FLAGS); |
---|
| 50 | test_iarchive ia(is); |
---|
| 51 | ia >> boost::serialization::make_nvp("alist",alist1); |
---|
| 52 | } |
---|
| 53 | BOOST_CHECK(alist == alist1); |
---|
| 54 | |
---|
| 55 | #ifdef BOOST_HAS_SLIST |
---|
| 56 | BOOST_STD_EXTENSION_NAMESPACE::slist<A> aslist; |
---|
| 57 | aslist.push_front(A()); |
---|
| 58 | aslist.push_front(A()); |
---|
| 59 | { |
---|
| 60 | test_ostream os(testfile, TEST_STREAM_FLAGS); |
---|
| 61 | test_oarchive oa(os); |
---|
| 62 | oa << boost::serialization::make_nvp("aslist", aslist); |
---|
| 63 | } |
---|
| 64 | BOOST_STD_EXTENSION_NAMESPACE::slist<A> aslist1;{ |
---|
| 65 | test_istream is(testfile, TEST_STREAM_FLAGS); |
---|
| 66 | test_iarchive ia(is); |
---|
| 67 | ia >> boost::serialization::make_nvp("aslist", aslist1); |
---|
| 68 | } |
---|
| 69 | BOOST_CHECK(aslist == aslist1); |
---|
| 70 | |
---|
| 71 | #endif |
---|
| 72 | std::remove(testfile); |
---|
| 73 | return EXIT_SUCCESS; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | // EOF |
---|
| 77 | |
---|