test_simple_class.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <cstddef> // NULL
  10. #include <cstdio> // remove
  11. #include <fstream>
  12. #include <cmath>
  13. #include <boost/math/special_functions/next.hpp>
  14. #include <boost/config.hpp>
  15. #if defined(BOOST_NO_STDC_NAMESPACE)
  16. namespace std{
  17. using ::remove;
  18. }
  19. #endif
  20. #include "test_tools.hpp"
  21. #include "A.hpp"
  22. #include "A.ipp"
  23. bool A::check_equal(const A &rhs) const
  24. {
  25. BOOST_CHECK_EQUAL(b, rhs.b);
  26. BOOST_CHECK_EQUAL(l, rhs.l);
  27. #ifndef BOOST_NO_INT64_T
  28. BOOST_CHECK_EQUAL(f, rhs.f);
  29. BOOST_CHECK_EQUAL(g, rhs.g);
  30. #endif
  31. BOOST_CHECK_EQUAL(m, rhs.m);
  32. BOOST_CHECK_EQUAL(n, rhs.n);
  33. BOOST_CHECK_EQUAL(o, rhs.o);
  34. BOOST_CHECK_EQUAL(p, rhs.p);
  35. BOOST_CHECK_EQUAL(q, rhs.q);
  36. #ifndef BOOST_NO_CWCHAR
  37. BOOST_CHECK_EQUAL(r, rhs.r);
  38. #endif
  39. BOOST_CHECK_EQUAL(c, rhs.c);
  40. BOOST_CHECK_EQUAL(s, rhs.s);
  41. BOOST_CHECK_EQUAL(t, rhs.t);
  42. BOOST_CHECK_EQUAL(u, rhs.u);
  43. BOOST_CHECK_EQUAL(v, rhs.v);
  44. BOOST_CHECK_EQUAL(l, rhs.l);
  45. BOOST_CHECK(std::abs( boost::math::float_distance(w, rhs.w)) < 2);
  46. BOOST_CHECK(std::abs( boost::math::float_distance(x, rhs.x)) < 2);
  47. BOOST_CHECK(!(0 != y.compare(rhs.y)));
  48. #ifndef BOOST_NO_STD_WSTRING
  49. BOOST_CHECK(!(0 != z.compare(rhs.z)));
  50. #endif
  51. return true;
  52. }
  53. int
  54. test_main( int /* argc */, char* /* argv */[] )
  55. {
  56. const char * testfile = boost::archive::tmpnam(NULL);
  57. BOOST_REQUIRE(NULL != testfile);
  58. A a, a1;
  59. {
  60. test_ostream os(testfile, TEST_STREAM_FLAGS);
  61. test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
  62. oa << boost::serialization::make_nvp("a", a);
  63. }
  64. {
  65. test_istream is(testfile, TEST_STREAM_FLAGS);
  66. test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
  67. ia >> boost::serialization::make_nvp("a", a1);
  68. }
  69. a.check_equal(a1);
  70. std::remove(testfile);
  71. return 0;
  72. }