test_stack.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  2. // test_stack.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>
  9. #include <fstream>
  10. #include <cstdio> // remove
  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 <boost/serialization/nvp.hpp>
  19. #include <boost/serialization/deque.hpp>
  20. #include <boost/serialization/stack.hpp>
  21. #include "A.hpp"
  22. #include "A.ipp"
  23. int test_main( int /* argc */, char* /* argv */[] )
  24. {
  25. const char * testfile = boost::archive::tmpnam(NULL);
  26. BOOST_REQUIRE(NULL != testfile);
  27. // test array of objects
  28. std::stack<A, std::deque<A> > astack, astack1;
  29. astack.push(A());
  30. astack.push(A());
  31. {
  32. test_ostream os(testfile, TEST_STREAM_FLAGS);
  33. test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
  34. oa << boost::serialization::make_nvp("astack",astack);
  35. }
  36. {
  37. test_istream is(testfile, TEST_STREAM_FLAGS);
  38. test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
  39. ia >> boost::serialization::make_nvp("astack",astack1);
  40. }
  41. BOOST_CHECK(astack == astack1);
  42. std::remove(testfile);
  43. return EXIT_SUCCESS;
  44. }
  45. // EOF