]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/test/test_set.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / serialization / test / test_set.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // test_set.cpp
3
4 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
5 // (C) Copyright 2014 Jim Bell
6 // Use, modification and distribution is subject to the Boost Software
7 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9
10 // should pass compilation and execution
11
12 #include <cstddef> // NULLsize_t
13 #include <cstdio> // remove
14 #include <fstream>
15
16 #include <algorithm> // std::copy
17 #include <vector>
18
19 #include <boost/config.hpp>
20 #if defined(BOOST_NO_STDC_NAMESPACE)
21 namespace std{
22 using ::size_t;
23 }
24 #endif
25
26 #include <boost/detail/workaround.hpp>
27 #if defined(BOOST_NO_STDC_NAMESPACE)
28 namespace std{
29 using ::remove;
30 }
31 #endif
32
33 #include <boost/archive/archive_exception.hpp>
34
35 #include "test_tools.hpp"
36
37 #include <boost/serialization/nvp.hpp>
38 #include <boost/serialization/set.hpp>
39
40 #include "A.hpp"
41 #include "A.ipp"
42
43 void
44 test_set(){
45 const char * testfile = boost::archive::tmpnam(NULL);
46 BOOST_REQUIRE(NULL != testfile);
47
48 // test array of objects
49 std::set<A> aset;
50 aset.insert(A());
51 aset.insert(A());
52 {
53 test_ostream os(testfile, TEST_STREAM_FLAGS);
54 test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
55 oa << boost::serialization::make_nvp("aset", aset);
56 }
57 std::set<A> aset1;
58 {
59 test_istream is(testfile, TEST_STREAM_FLAGS);
60 test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
61 ia >> boost::serialization::make_nvp("aset", aset1);
62 }
63 BOOST_CHECK(aset == aset1);
64 std::remove(testfile);
65 }
66
67 void
68 test_multiset(){
69 const char * testfile = boost::archive::tmpnam(NULL);
70 BOOST_REQUIRE(NULL != testfile);
71
72 std::multiset<A> amultiset;
73 amultiset.insert(A());
74 amultiset.insert(A());
75 {
76 test_ostream os(testfile, TEST_STREAM_FLAGS);
77 test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
78 oa << boost::serialization::make_nvp("amultiset", amultiset);
79 }
80 std::multiset<A> amultiset1;
81 {
82 test_istream is(testfile, TEST_STREAM_FLAGS);
83 test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
84 ia >> boost::serialization::make_nvp("amultiset", amultiset1);
85 }
86 BOOST_CHECK(amultiset == amultiset1);
87 std::remove(testfile);
88 }
89
90 int test_main( int /* argc */, char* /* argv */[] ){
91 test_set();
92 test_multiset();
93
94 return EXIT_SUCCESS;
95 }