1 | /*!
|
---|
2 | * \file test_bitset.cpp
|
---|
3 | * \brief Test that serialization of std::bitset works.
|
---|
4 | * \note Should pass compilation and execution
|
---|
5 | * \author Brian Ravnsgaard Riis
|
---|
6 | * \author Kenneth Riddile
|
---|
7 | * \date 16.09.2004, updated 04.03.2009
|
---|
8 | * \license Boost Software License 1.0
|
---|
9 | */
|
---|
10 |
|
---|
11 | #include <cstddef> // NULL
|
---|
12 | #include <cstdio> // remove
|
---|
13 | #include <fstream>
|
---|
14 |
|
---|
15 | #include <boost/config.hpp>
|
---|
16 |
|
---|
17 | #if defined( BOOST_NO_STDC_NAMESPACE )
|
---|
18 | namespace std
|
---|
19 | {
|
---|
20 | using ::remove;
|
---|
21 | }
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "test_tools.hpp"
|
---|
25 |
|
---|
26 | #include <boost/serialization/bitset.hpp>
|
---|
27 | #include <boost/serialization/nvp.hpp>
|
---|
28 |
|
---|
29 | int test_main( int /* argc */, char* /* argv */[] )
|
---|
30 | {
|
---|
31 | const char* testfile = boost::archive::tmpnam( NULL );
|
---|
32 | BOOST_REQUIRE( NULL != testfile );
|
---|
33 |
|
---|
34 | std::bitset<8> bitsetA;
|
---|
35 | bitsetA.set( 0, false );
|
---|
36 | bitsetA.set( 1, true );
|
---|
37 | bitsetA.set( 2, false );
|
---|
38 | bitsetA.set( 3, true );
|
---|
39 | bitsetA.set( 4, false );
|
---|
40 | bitsetA.set( 5, false );
|
---|
41 | bitsetA.set( 6, true );
|
---|
42 | bitsetA.set( 7, true );
|
---|
43 |
|
---|
44 | {
|
---|
45 | test_ostream os( testfile, TEST_STREAM_FLAGS );
|
---|
46 | test_oarchive oa( os );
|
---|
47 | oa << boost::serialization::make_nvp( "bitset", bitsetA );
|
---|
48 | }
|
---|
49 |
|
---|
50 | std::bitset<8> bitsetB;
|
---|
51 | {
|
---|
52 | test_istream is( testfile, TEST_STREAM_FLAGS );
|
---|
53 | test_iarchive ia( is );
|
---|
54 | ia >> boost::serialization::make_nvp( "bitset", bitsetB );
|
---|
55 | }
|
---|
56 |
|
---|
57 | BOOST_CHECK( bitsetA == bitsetB );
|
---|
58 |
|
---|
59 | std::remove( testfile );
|
---|
60 | return EXIT_SUCCESS;
|
---|
61 | }
|
---|
62 |
|
---|
63 | // EOF
|
---|