1 | /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 |
2 | // test_nvp.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 <cstddef> // NULL |
12 | #include <cstdio> // remove |
13 | #include <fstream> |
14 | |
15 | #include <boost/config.hpp> |
16 | #if defined(BOOST_NO_STDC_NAMESPACE) |
17 | namespace std{ |
18 | using ::remove; |
19 | } |
20 | #endif |
21 | |
22 | #include "test_tools.hpp" |
23 | |
24 | #include <boost/serialization/nvp.hpp> |
25 | |
26 | #include "B.hpp" |
27 | #include "A.ipp" |
28 | |
29 | int |
30 | test_main( int /* argc */, char* /* argv */[] ) |
31 | { |
32 | const char * testfile = boost::archive::tmpnam(NULL); |
33 | BOOST_REQUIRE(NULL != testfile); |
34 | |
35 | B b, b1; |
36 | |
37 | { |
38 | test_ostream os(testfile, TEST_STREAM_FLAGS); |
39 | test_oarchive oa(os, TEST_ARCHIVE_FLAGS); |
40 | oa << BOOST_SERIALIZATION_NVP(b); |
41 | } |
42 | { |
43 | test_istream is(testfile, TEST_STREAM_FLAGS); |
44 | test_iarchive ia(is, TEST_ARCHIVE_FLAGS); |
45 | ia >> BOOST_SERIALIZATION_NVP(b1); |
46 | } |
47 | BOOST_CHECK(b == b1); |
48 | |
49 | B *bptr = &b; |
50 | B *bptr1; |
51 | |
52 | { |
53 | test_ostream os(testfile, TEST_STREAM_FLAGS); |
54 | test_oarchive oa(os, TEST_ARCHIVE_FLAGS); |
55 | oa << BOOST_SERIALIZATION_NVP(bptr); |
56 | } |
57 | { |
58 | test_istream is(testfile, TEST_STREAM_FLAGS); |
59 | test_iarchive ia(is, TEST_ARCHIVE_FLAGS); |
60 | ia >> BOOST_SERIALIZATION_NVP(bptr1); |
61 | } |
62 | BOOST_CHECK(b == *bptr1); |
63 | |
64 | std::remove(filename: testfile); |
65 | return EXIT_SUCCESS; |
66 | } |
67 | |
68 | // EOF |
69 | |