メインページ | ネームスペース一覧 | クラス階層 | 構成 | ファイル一覧 | ネームスペースメンバ | 構成メンバ | ファイルメンバ | 関連ページ

list_test.cpp

説明を見る。
00001 #include "static_container/test/assert_new.h"
00002 #include <boost/test/minimal.hpp>
00003 #include "static_container/list.h"
00004 #include "static_container/test/basic_sequence.h"
00005 #include <iterator>
00006 #include <boost/iterator/counting_iterator.hpp>
00007 
00008 using namespace static_container;
00009 
00010 struct listgen {
00011     template < typename Value, size_type Size >
00012     struct gen {
00013         typedef list< Value, Size > type;
00014     };
00015 };
00016 
00017 void test_lodge_list() {
00018     list_node_pool< int, 10 >   pool;
00019     lodge_list< int >   list0( pool );
00020     lodge_list< int >   list1( pool );
00021     lodge_list< int >   list2( pool );
00022     
00023     BOOST_REQUIRE( 10 == pool.rest() );
00024     BOOST_REQUIRE( list0.empty() );
00025     list0.push_back( 100 );
00026     BOOST_REQUIRE( 1 == list0.size() );
00027     BOOST_REQUIRE( 9 == pool.rest() );
00028     BOOST_REQUIRE( 100 == list0.front() );
00029     
00030     list1.push_back( 10 );
00031     list2.push_back( 5 );
00032     list0.push_back( 9 );
00033     BOOST_REQUIRE( 6 == pool.rest() );
00034     list1.pop_back();
00035     BOOST_REQUIRE( 7 == pool.rest() );
00036     
00037     //  クリアされるのは、list0 のみ
00038     list0.clear();
00039     BOOST_REQUIRE( list0.empty() );
00040     BOOST_REQUIRE( 9 == pool.rest() );  // 他のリストが所有するノードはまだ返却されていない
00041     
00042     std::copy( boost::counting_iterator< int >( 0 ), boost::counting_iterator< int >( pool.rest() ), std::back_inserter( list1 ) );
00043     BOOST_REQUIRE( 0 == pool.rest() );
00044     
00045     BOOST_REQUIRE( list1.end() != std::find( list1.begin(), list1.end(), 5 ) );
00046     lodge_list< int >::iterator it = list1.begin();
00047     std::advance( it, 5 );
00048     list1.erase( it );
00049     BOOST_REQUIRE( list1.end() == std::find( list1.begin(), list1.end(), 5 ) );
00050 }
00051 
00052 int test_main( int argc, char* argv[] ) {
00053     test::begin(); // new 呼び出しに怒り狂う!
00054     test::basic_sequence< listgen >();
00055     test_lodge_list();
00056     return 0;
00057 }

static_containerに対してSat Jun 19 11:30:58 2004に生成されました。 doxygen 1.3.6