1 // (C) Copyright Andy Tompkins 2007. Permission to copy, use, modify, sell and
2 // distribute this software is granted provided this copyright notice appears
3 // in all copies. This software is provided "as is" without express or implied
4 // warranty, and with no claim as to its suitability for any purpose.
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // https://www.boost.org/LICENSE_1_0.txt)
10 // Purpose to test serializing uuids with narrow archives
12 #include <boost/detail/lightweight_test.hpp>
16 #include <boost/uuid/uuid.hpp>
17 #include <boost/uuid/uuid_serialize.hpp>
18 #include <boost/uuid/uuid_io.hpp>
20 #include <boost/archive/text_oarchive.hpp>
21 #include <boost/archive/text_iarchive.hpp>
23 #include <boost/archive/xml_oarchive.hpp>
24 #include <boost/archive/xml_iarchive.hpp>
26 #include <boost/archive/binary_oarchive.hpp>
27 #include <boost/archive/binary_iarchive.hpp>
29 template <class OArchiveType
, class IArchiveType
, class OStringStreamType
, class IStringStreamType
>
33 using namespace boost::uuids
;
35 OStringStreamType o_stream
;
37 uuid u1
= {{0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef}};
43 OArchiveType
oa(o_stream
);
45 oa
<< BOOST_SERIALIZATION_NVP(u1
);
48 //cout << "stream:" << o_stream.str() << "\n\n";
52 IStringStreamType
i_stream(o_stream
.str());
53 IArchiveType
ia(i_stream
);
55 ia
>> BOOST_SERIALIZATION_NVP(u2
);
58 BOOST_TEST_EQ(u1
, u2
);
61 int main( int /* argc */, char* /* argv */[] )
64 using namespace boost::archive
;
66 test_archive
<text_oarchive
, text_iarchive
, ostringstream
, istringstream
>();
67 test_archive
<xml_oarchive
, xml_iarchive
, ostringstream
, istringstream
>();
68 test_archive
<binary_oarchive
, binary_iarchive
, ostringstream
, istringstream
>();
70 return boost::report_errors();