1/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2// test_priority_queue.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#include <cstddef>
12#include <fstream>
13
14#include <cstdio> // remove
15#include <boost/config.hpp>
16#if defined(BOOST_NO_STDC_NAMESPACE)
17namespace std{
18 using ::remove;
19}
20#endif
21
22#include "test_tools.hpp"
23
24#include <boost/serialization/vector.hpp>
25#include <boost/serialization/priority_queue.hpp>
26
27#include "A.hpp"
28#include "A.ipp"
29
30int test_main( int /* argc */, char* /* argv */[] )
31{
32 const char * testfile = boost::archive::tmpnam(NULL);
33 BOOST_REQUIRE(NULL != testfile);
34
35 // test array of objects
36 std::priority_queue<A, std::vector<A> > a_priority_queue, a_priority_queue1;
37 a_priority_queue.push(x: A());
38 a_priority_queue.push(x: A());
39 a_priority_queue.push(x: A());
40 a_priority_queue.push(x: A());
41 {
42 test_ostream os(testfile, TEST_STREAM_FLAGS);
43 test_oarchive oa(os, TEST_ARCHIVE_FLAGS);
44 oa << boost::serialization::make_nvp(n: "a_priority_queue",v&: a_priority_queue);
45 }
46 {
47 test_istream is(testfile, TEST_STREAM_FLAGS);
48 test_iarchive ia(is, TEST_ARCHIVE_FLAGS);
49 ia >> boost::serialization::make_nvp(n: "a_priority_queue",v&: a_priority_queue1);
50 }
51 BOOST_CHECK(a_priority_queue.size() == a_priority_queue1.size());
52
53 for(int i = a_priority_queue.size(); i-- > 0;){
54 const A & a1 = a_priority_queue.top();
55 const A & a2 = a_priority_queue1.top();
56 BOOST_CHECK(a1 == a2);
57 a_priority_queue.pop();
58 a_priority_queue1.pop();
59 }
60
61 std::remove(filename: testfile);
62 return EXIT_SUCCESS;
63}
64
65// EOF
66

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