1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 2 // test_polymorphic2.cpp 3 4 // (C) Copyright 2009 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 #include <fstream> 11 12 #include "test_tools.hpp" 13 14 #include "test_polymorphic2.hpp" 15 test_main(int,char * [])16int test_main(int /*argc*/, char* /*argv*/[]) 17 { 18 A *a = new B(); 19 a->i = 3; 20 21 const char * testfile = boost::archive::tmpnam(NULL); 22 BOOST_REQUIRE(NULL != testfile); 23 { 24 test_ostream os(testfile, TEST_STREAM_FLAGS); 25 test_oarchive oa_implementation(os, TEST_ARCHIVE_FLAGS); 26 boost::archive::polymorphic_oarchive & opa = oa_implementation; 27 opa << BOOST_SERIALIZATION_NVP(a); 28 } 29 A *loaded = 0; 30 { 31 test_istream is(testfile, TEST_STREAM_FLAGS); 32 test_iarchive ia_implementation(is, TEST_ARCHIVE_FLAGS); 33 boost::archive::polymorphic_iarchive & ipa = ia_implementation; 34 ipa >> BOOST_SERIALIZATION_NVP(loaded); 35 } 36 BOOST_CHECK(a->i == loaded->i); 37 delete a; 38 delete loaded; 39 return EXIT_SUCCESS; 40 } 41