test_deque.cpp 1.4 KB

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