Boost logo

Boost-Commit :

From: nesotto_at_[hidden]
Date: 2008-06-12 10:14:32


Author: nesotto
Date: 2008-06-12 10:14:32 EDT (Thu, 12 Jun 2008)
New Revision: 46354
URL: http://svn.boost.org/trac/boost/changeset/46354

Log:
update of test for ptr_unordered_set
Text files modified:
   trunk/libs/ptr_container/test/serialization.cpp | 43 +++++++++++++++++++++++++++++++--------
   1 files changed, 34 insertions(+), 9 deletions(-)

Modified: trunk/libs/ptr_container/test/serialization.cpp
==============================================================================
--- trunk/libs/ptr_container/test/serialization.cpp (original)
+++ trunk/libs/ptr_container/test/serialization.cpp 2008-06-12 10:14:32 EDT (Thu, 12 Jun 2008)
@@ -143,6 +143,7 @@
     set_capacity<Cont>()( vec );
     add( vec, new Base( -1 ), 0u );
     add( vec, new Derived( 1 ), 1u );
+ BOOST_CHECK_EQUAL( vec.size(), 2u );
 
     std::ofstream ofs("filename");
     OArchive oa(ofs);
@@ -167,6 +168,32 @@
 
 }
 
+template< class Cont, class OArchive, class IArchive >
+void test_serialization_unordered_set_helper()
+{
+ Cont vec;
+ set_capacity<Cont>()( vec );
+ add( vec, new Base( -1 ), 0u );
+ add( vec, new Derived( 1 ), 1u );
+ BOOST_CHECK_EQUAL( vec.size(), 2u );
+
+ std::ofstream ofs("filename");
+ OArchive oa(ofs);
+ oa << boost::serialization::make_nvp( "container", as_const(vec) );
+ ofs.close();
+
+
+ std::ifstream ifs("filename", std::ios::binary);
+ IArchive ia(ifs);
+ Cont vec2;
+ ia >> boost::serialization::make_nvp( "container", vec2 );
+ ifs.close();
+
+ BOOST_CHECK_EQUAL( vec.size(), vec2.size() );
+ BOOST_CHECK_EQUAL( (*vec2.begin()).i, 0 );
+ BOOST_CHECK_EQUAL( (*++vec2.begin()).i, -1 );
+}
+
 template< class Map, class OArchive, class IArchive >
 void test_serialization_map_helper()
 {
@@ -255,16 +282,14 @@
     test_serialization_helper< boost::ptr_multiset<Base>,
                                boost::archive::text_oarchive,
                                boost::archive::text_iarchive>();
- /*test_serialization_helper< boost::ptr_unordered_set<Base>,
- boost::archive::text_oarchive,
- boost::archive::text_iarchive>();
- test_serialization_helper< boost::ptr_unordered_multiset<Base>,
- boost::archive::text_oarchive,
- boost::archive::text_iarchive>();
+
+ test_serialization_unordered_set_helper< boost::ptr_unordered_set<Base>,
+ boost::archive::text_oarchive,
+ boost::archive::text_iarchive>();
+ test_serialization_unordered_set_helper<boost::ptr_unordered_multiset<Base>,
+ boost::archive::text_oarchive,
+ boost::archive::text_iarchive>();
                                
- @todo: fix ordernig issue here...
- */
-
     test_serialization_map_helper< boost::ptr_map<std::string,Base>,
                                    boost::archive::text_oarchive,
                                    boost::archive::text_iarchive>();


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk