performance_simple_class.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
  2. // test_simple_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. // invoke header for a custom archive test.
  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/test_tools.hpp"
  18. #include <boost/preprocessor/stringize.hpp>
  19. // #include <boost/preprocessor/cat.hpp>
  20. // the following fails with (only!) gcc 3.4
  21. // #include BOOST_PP_STRINGIZE(BOOST_PP_CAT(../test/,BOOST_ARCHIVE_TEST))
  22. // just copy over the files from the test directory
  23. #include BOOST_PP_STRINGIZE(BOOST_ARCHIVE_TEST)
  24. #include <boost/serialization/nvp.hpp>
  25. #include "../test/A.hpp"
  26. int
  27. test_main( int /* argc */, char* /* argv */[] )
  28. {
  29. const char * testfile = boost::archive::tmpnam(NULL);
  30. BOOST_REQUIRE(NULL != testfile);
  31. A a, a1;
  32. {
  33. test_ostream os(testfile, TEST_STREAM_FLAGS);
  34. test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
  35. oa << boost::serialization::make_nvp("a", a);
  36. }
  37. {
  38. test_istream is(testfile, TEST_STREAM_FLAGS);
  39. test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
  40. ia >> boost::serialization::make_nvp("a", a1);
  41. }
  42. BOOST_CHECK_EQUAL(a, a1);
  43. std::remove(testfile);
  44. return (a == a1) ? EXIT_SUCCESS : EXIT_SUCCESS;
  45. }