]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/test/test_simple_class.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / serialization / test / test_simple_class.cpp
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 #include <boost/math/special_functions/next.hpp>
18
19 #include <boost/config.hpp>
20
21 #if defined(BOOST_NO_STDC_NAMESPACE)
22 namespace std{
23 using ::remove;
24 }
25 #endif
26
27 #include "test_tools.hpp"
28
29 #include "A.hpp"
30 #include "A.ipp"
31
32 bool A::check_equal(const A &rhs) const
33 {
34 BOOST_CHECK_EQUAL(b, rhs.b);
35 BOOST_CHECK_EQUAL(l, rhs.l);
36 #ifndef BOOST_NO_INT64_T
37 BOOST_CHECK_EQUAL(f, rhs.f);
38 BOOST_CHECK_EQUAL(g, rhs.g);
39 #endif
40 BOOST_CHECK_EQUAL(m, rhs.m);
41 BOOST_CHECK_EQUAL(n, rhs.n);
42 BOOST_CHECK_EQUAL(o, rhs.o);
43 BOOST_CHECK_EQUAL(p, rhs.p);
44 BOOST_CHECK_EQUAL(q, rhs.q);
45 #ifndef BOOST_NO_CWCHAR
46 BOOST_CHECK_EQUAL(r, rhs.r);
47 #endif
48 BOOST_CHECK_EQUAL(c, rhs.c);
49 BOOST_CHECK_EQUAL(s, rhs.s);
50 BOOST_CHECK_EQUAL(t, rhs.t);
51 BOOST_CHECK_EQUAL(u, rhs.u);
52 BOOST_CHECK_EQUAL(v, rhs.v);
53 BOOST_CHECK_EQUAL(l, rhs.l);
54 BOOST_CHECK(std::abs( boost::math::float_distance(w, rhs.w)) < 2);
55 BOOST_CHECK(std::abs( boost::math::float_distance(x, rhs.x)) < 2);
56 BOOST_CHECK(!(0 != y.compare(rhs.y)));
57 #ifndef BOOST_NO_STD_WSTRING
58 BOOST_CHECK(!(0 != z.compare(rhs.z)));
59 #endif
60 return true;
61 }
62
63 int
64 test_main( int /* argc */, char* /* argv */[] )
65 {
66 const char * testfile = boost::archive::tmpnam(NULL);
67 BOOST_REQUIRE(NULL != testfile);
68
69 A a, a1;
70 {
71 test_ostream os(testfile, TEST_STREAM_FLAGS);
72 test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
73 oa << boost::serialization::make_nvp("a", a);
74 }
75 {
76 test_istream is(testfile, TEST_STREAM_FLAGS);
77 test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
78 ia >> boost::serialization::make_nvp("a", a1);
79 }
80 a.check_equal(a1);
81 std::remove(testfile);
82 return 0;
83 }