test_recursion.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  2. // test_recurrsion.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 <cstddef> // NULL
  9. #include <cstdio> // remove
  10. #include <fstream>
  11. #include <boost/config.hpp>
  12. #if defined(BOOST_NO_STDC_NAMESPACE)
  13. namespace std{
  14. using ::remove;
  15. }
  16. #endif
  17. #include "test_tools.hpp"
  18. #include "J.hpp"
  19. #include "A.ipp"
  20. int test_main( int /* argc */, char* /* argv */[] )
  21. {
  22. const char * testfile = boost::archive::tmpnam(NULL);
  23. BOOST_REQUIRE(NULL != testfile);
  24. // test recursive structure
  25. J j, j1;
  26. j.j = &j;
  27. {
  28. test_ostream os(testfile, TEST_STREAM_FLAGS);
  29. test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
  30. oa << BOOST_SERIALIZATION_NVP(j);
  31. }
  32. {
  33. test_istream is(testfile, TEST_STREAM_FLAGS);
  34. test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
  35. ia >> BOOST_SERIALIZATION_NVP(j1);
  36. }
  37. BOOST_CHECK(j == j1);
  38. std::remove(testfile);
  39. return EXIT_SUCCESS;
  40. }
  41. // EOF