1/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2// test_simple_class.cpp
3
4// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5// Use, modification and distribution is subject to the Boost Software
6// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8
9// should pass compilation and execution
10
11// invoke header for a custom archive test.
12
13#include <cstddef> // NULL
14#include <cstdio> // remove
15#include <fstream>
16#include <cmath>
17
18#include <boost/config.hpp>
19#if BOOST_CXX_VERSION > 199711L // only include floating point if C++ version >= C++11
20#include <boost/math/special_functions/next.hpp>
21#endif
22
23#if defined(BOOST_NO_STDC_NAMESPACE)
24namespace std{
25 using ::remove;
26}
27#endif
28
29#include "test_tools.hpp"
30
31#include "A.hpp"
32#include "A.ipp"
33
34bool A::check_equal(const A &rhs) const
35{
36 BOOST_CHECK_EQUAL(b, rhs.b);
37 BOOST_CHECK_EQUAL(l, rhs.l);
38 #ifndef BOOST_NO_INT64_T
39 BOOST_CHECK_EQUAL(f, rhs.f);
40 BOOST_CHECK_EQUAL(g, rhs.g);
41 #endif
42 BOOST_CHECK_EQUAL(m, rhs.m);
43 BOOST_CHECK_EQUAL(n, rhs.n);
44 BOOST_CHECK_EQUAL(o, rhs.o);
45 BOOST_CHECK_EQUAL(p, rhs.p);
46 BOOST_CHECK_EQUAL(q, rhs.q);
47 #ifndef BOOST_NO_CWCHAR
48 BOOST_CHECK_EQUAL(r, rhs.r);
49 #endif
50 BOOST_CHECK_EQUAL(c, rhs.c);
51 BOOST_CHECK_EQUAL(s, rhs.s);
52 BOOST_CHECK_EQUAL(t, rhs.t);
53 BOOST_CHECK_EQUAL(u, rhs.u);
54 BOOST_CHECK_EQUAL(v, rhs.v);
55 BOOST_CHECK_EQUAL(l, rhs.l);
56 #if BOOST_CXX_VERSION > 199711L // only include floating point if C++ version >= C++11
57 BOOST_CHECK(std::abs( boost::math::float_distance(w, rhs.w)) < 2);
58 BOOST_CHECK(std::abs( boost::math::float_distance(x, rhs.x)) < 2);
59 #endif
60 BOOST_CHECK(!(0 != y.compare(rhs.y)));
61 #ifndef BOOST_NO_STD_WSTRING
62 BOOST_CHECK(!(0 != z.compare(rhs.z)));
63 #endif
64 return true;
65}
66
67int
68test_main( int /* argc */, char* /* argv */[] )
69{
70 const char * testfile = boost::archive::tmpnam(NULL);
71 BOOST_REQUIRE(NULL != testfile);
72
73 A a, a1;
74 {
75 test_ostream os(testfile, TEST_STREAM_FLAGS);
76 test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
77 oa << boost::serialization::make_nvp(n: "a", v&: a);
78 }
79 {
80 test_istream is(testfile, TEST_STREAM_FLAGS);
81 test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
82 ia >> boost::serialization::make_nvp(n: "a", v&: a1);
83 }
84 a.check_equal(rhs: a1);
85 std::remove(filename: testfile);
86 return 0;
87}
88

source code of boost/libs/serialization/test/test_simple_class.cpp