test_derived_class.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  2. // test_derived_class.cpp
  3. // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
  4. // Use, modification and distribution is subject to the Boost Software
  5. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. // should pass compilation and execution
  8. #include <fstream>
  9. #include <cstdio> // remove
  10. #include <boost/config.hpp>
  11. #if defined(BOOST_NO_STDC_NAMESPACE)
  12. namespace std{
  13. using ::remove;
  14. }
  15. #endif
  16. #include "test_tools.hpp"
  17. #include "B.hpp"
  18. #include "A.ipp"
  19. int test_main( int /*argc*/, char* /*argv*/[] )
  20. {
  21. const char * testfile = boost::archive::tmpnam(NULL);
  22. BOOST_REQUIRE(NULL != testfile);
  23. B b, b1;
  24. {
  25. test_ostream os(testfile, TEST_STREAM_FLAGS);
  26. test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
  27. oa << boost::serialization::make_nvp("b", b);
  28. }
  29. {
  30. test_istream is(testfile, TEST_STREAM_FLAGS);
  31. test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
  32. ia >> boost::serialization::make_nvp("b1", b1);
  33. }
  34. BOOST_CHECK(b == b1);
  35. std::remove(testfile);
  36. return EXIT_SUCCESS;
  37. }
  38. // EOF