From 4c784f8c28c9c4cd7a23c2262afa6b1483da83dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 12 May 2007 12:34:55 +0000 Subject: [PATCH] Changes to correct regression tests for intel-win-9.1 & cw-9.4 [SVN r37675] --- doc/intrusive.qbk | 2 +- example/doc_advanced_value_traits.cpp | 2 +- example/doc_assoc_optimized_code.cpp | 2 +- example/doc_auto_unlink.cpp | 2 +- example/doc_clone_from.cpp | 2 +- example/doc_entity.cpp | 2 +- example/doc_erasing_and_destroying.cpp | 2 +- example/doc_how_to_use.cpp | 2 +- example/doc_iterator_from_value.cpp | 2 +- example/doc_list.cpp | 2 +- example/doc_list_algorithms.cpp | 2 +- example/doc_offset_ptr.cpp | 2 +- example/doc_rbtree_algorithms.cpp | 2 +- example/doc_set.cpp | 4 +- example/doc_slist.cpp | 2 +- example/doc_slist_algorithms.cpp | 2 +- example/doc_unordered_set.cpp | 3 +- example/doc_value_traits.cpp | 2 +- example/doc_window.cpp | 2 +- perf/perf_list.cpp | 2 +- .../vc7ide/_intrusivelib/_intrusivelib.vcproj | 585 +++++++++--------- test/common_functors.hpp | 7 +- test/itestvalue.hpp | 203 +++--- test/list_test.cpp | 190 +++--- test/multiset_test.cpp | 117 ++-- test/set_test.cpp | 116 ++-- test/slist_test.cpp | 216 +++---- test/smart_ptr.hpp | 26 +- test/test_container.hpp | 2 +- test/test_macros.hpp | 29 + test/unordered_multiset_test.cpp | 181 +++--- test/unordered_set_test.cpp | 151 ++--- 32 files changed, 861 insertions(+), 1005 deletions(-) create mode 100644 test/test_macros.hpp diff --git a/doc/intrusive.qbk b/doc/intrusive.qbk index 9065b99..2682900 100644 --- a/doc/intrusive.qbk +++ b/doc/intrusive.qbk @@ -2410,7 +2410,7 @@ helpful discussions. * [*Jaap Suter] for the initial hint, which eventually leads to the member value_traits. -[*Ion GaztaÃąaga] would like to thank: +[*Ion Gaztanaga] would like to thank: * [*Olaf Krzikalla] for the permission to continue his great work. diff --git a/example/doc_advanced_value_traits.cpp b/example/doc_advanced_value_traits.cpp index 1d4b018..bdcd4ca 100644 --- a/example/doc_advanced_value_traits.cpp +++ b/example/doc_advanced_value_traits.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_assoc_optimized_code.cpp b/example/doc_assoc_optimized_code.cpp index 594c643..18dfe70 100644 --- a/example/doc_assoc_optimized_code.cpp +++ b/example/doc_assoc_optimized_code.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_auto_unlink.cpp b/example/doc_auto_unlink.cpp index e068aec..7e048a7 100644 --- a/example/doc_auto_unlink.cpp +++ b/example/doc_auto_unlink.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_clone_from.cpp b/example/doc_clone_from.cpp index f61f3c4..c1351c1 100644 --- a/example/doc_clone_from.cpp +++ b/example/doc_clone_from.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_entity.cpp b/example/doc_entity.cpp index efbb96c..4df09e4 100644 --- a/example/doc_entity.cpp +++ b/example/doc_entity.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_erasing_and_destroying.cpp b/example/doc_erasing_and_destroying.cpp index d6634ad..a6759e0 100644 --- a/example/doc_erasing_and_destroying.cpp +++ b/example/doc_erasing_and_destroying.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_how_to_use.cpp b/example/doc_how_to_use.cpp index 5342b46..30933a9 100644 --- a/example/doc_how_to_use.cpp +++ b/example/doc_how_to_use.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_iterator_from_value.cpp b/example/doc_iterator_from_value.cpp index c4135ce..4b935a6 100644 --- a/example/doc_iterator_from_value.cpp +++ b/example/doc_iterator_from_value.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_list.cpp b/example/doc_list.cpp index e695bb6..e923419 100644 --- a/example/doc_list.cpp +++ b/example/doc_list.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_list_algorithms.cpp b/example/doc_list_algorithms.cpp index 1e63330..0d1277d 100644 --- a/example/doc_list_algorithms.cpp +++ b/example/doc_list_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_offset_ptr.cpp b/example/doc_offset_ptr.cpp index e3765a2..c5c2c25 100644 --- a/example/doc_offset_ptr.cpp +++ b/example/doc_offset_ptr.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_rbtree_algorithms.cpp b/example/doc_rbtree_algorithms.cpp index e372859..d51d26d 100644 --- a/example/doc_rbtree_algorithms.cpp +++ b/example/doc_rbtree_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_set.cpp b/example/doc_set.cpp index a624a1e..443fd48 100644 --- a/example/doc_set.cpp +++ b/example/doc_set.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -34,6 +34,8 @@ class MyClass : public set_base_hook<> { return a.get() < b.get(); } friend bool operator> (const MyClass &a, const MyClass &b) { return a.get() > b.get(); } + friend bool operator== (const MyClass &a, const MyClass &b) + { return a.get() < b.get(); } }; //Define an set that will store MyClass diff --git a/example/doc_slist.cpp b/example/doc_slist.cpp index 67d4bde..d408662 100644 --- a/example/doc_slist.cpp +++ b/example/doc_slist.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_slist_algorithms.cpp b/example/doc_slist_algorithms.cpp index 779b6e8..d13d333 100644 --- a/example/doc_slist_algorithms.cpp +++ b/example/doc_slist_algorithms.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_unordered_set.cpp b/example/doc_unordered_set.cpp index c4e1c65..f561596 100644 --- a/example/doc_unordered_set.cpp +++ b/example/doc_unordered_set.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -107,4 +107,3 @@ int main() return 0; } //] - diff --git a/example/doc_value_traits.cpp b/example/doc_value_traits.cpp index f091da2..c29e4f0 100644 --- a/example/doc_value_traits.cpp +++ b/example/doc_value_traits.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/example/doc_window.cpp b/example/doc_window.cpp index 7154c46..dcb4875 100644 --- a/example/doc_window.cpp +++ b/example/doc_window.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/perf/perf_list.cpp b/perf/perf_list.cpp index 730b936..6118eb3 100644 --- a/perf/perf_list.cpp +++ b/perf/perf_list.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2007 +// (C) Copyright Ion Gaztanaga 2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj b/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj index cf7e5e9..1635d52 100644 --- a/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj +++ b/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj @@ -1,294 +1,297 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + ProjectType="Visual C++" + Version="7.10" + Name="_intrusivelib" + ProjectGUID="{90F3C5BD-8E6C-4629-BC71-A1009EC88059}" + Keyword="Win32Proj"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/common_functors.hpp b/test/common_functors.hpp index 928df60..7097f38 100644 --- a/test/common_functors.hpp +++ b/test/common_functors.hpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006-2007 +// (C) Copyright Ion Gaztanaga 2006-2007 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -13,6 +13,8 @@ #ifndef BOOST_INTRUSIVE_TEST_COMMON_FUNCTORS_HPP #define BOOST_INTRUSIVE_TEST_COMMON_FUNCTORS_HPP +#include + namespace boost { namespace intrusive { namespace test { @@ -23,8 +25,7 @@ public: template void operator()(Pointer p) { - using boost::get_pointer; - delete get_pointer(p); + delete detail::get_pointer(p); } }; diff --git a/test/itestvalue.hpp b/test/itestvalue.hpp index 04476a9..4af2d8d 100644 --- a/test/itestvalue.hpp +++ b/test/itestvalue.hpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztaņaga 2006-2007. +// (C) Copyright Ion Gaztanaga 2006-2007. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -13,17 +13,11 @@ #ifndef BOOST_INTRUSIVE_ITESTVALUE #define BOOST_INTRUSIVE_ITESTVALUE -#ifdef _MSC_VER -//#pragma warning(disable : 4584) -#endif - #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include "smart_ptr.hpp" namespace boost{ @@ -40,46 +34,39 @@ struct testvalue , slist_base_hook , slist_base_hook { - typedef set_base_hook set_auto_base_hook; - typedef set_base_hookset_base_hook; - typedef set_member_hook set_auto_member_hook; - typedef set_member_hook set_member_hook; + typedef set_base_hook set_auto_base_hook_t; + typedef set_base_hook set_base_hook_t; + typedef set_member_hook set_auto_member_hook_t; + typedef set_member_hook set_member_hook_t; - typedef unordered_set_base_hook unordered_set_auto_base_hook; - typedef unordered_set_base_hook unordered_set_base_hook; - typedef unordered_set_member_hook unordered_set_auto_member_hook; - typedef unordered_set_member_hook unordered_set_member_hook; + typedef unordered_set_base_hook unordered_set_auto_base_hook_t; + typedef unordered_set_base_hook unordered_set_base_hook_t; + typedef unordered_set_member_hook unordered_set_auto_member_hook_t; + typedef unordered_set_member_hook unordered_set_member_hook_t; - typedef list_base_hook list_auto_base_hook; - typedef list_base_hook list_base_hook; - typedef list_member_hook list_auto_member_hook; - typedef list_member_hook list_member_hook; + typedef list_base_hook list_auto_base_hook_t; + typedef list_base_hook list_base_hook_t; + typedef list_member_hook list_auto_member_hook_t; + typedef list_member_hook list_member_hook_t; - typedef slist_base_hook slist_auto_base_hook; - typedef slist_base_hook slist_base_hook; - typedef slist_member_hook slist_auto_member_hook; - typedef slist_member_hook slist_member_hook; - - typedef typename boost::pointer_to_other - ::type pointer; + typedef slist_base_hook slist_auto_base_hook_t; + typedef slist_base_hook slist_base_hook_t; + typedef slist_member_hook slist_auto_member_hook_t; + typedef slist_member_hook slist_member_hook_t; //Set members - //pointer set_parent_, set_left_, set_right_; - //int set_color_; - set_member_hook set_node_; - set_auto_member_hook set_auto_node_; - unordered_set_member_hook unordered_set_node_; - unordered_set_auto_member_hook unordered_set_auto_node_; + set_member_hook_t set_node_; + set_auto_member_hook_t set_auto_node_; + unordered_set_member_hook_t unordered_set_node_; + unordered_set_auto_member_hook_t unordered_set_auto_node_; //List members - //pointer list_next_, list_prev_; - list_member_hook list_node_; - list_auto_member_hook list_auto_node_; + list_member_hook_t list_node_; + list_auto_member_hook_t list_auto_node_; //Slist members - //pointer slist_next_; - slist_member_hook slist_node_; - slist_auto_member_hook slist_auto_node_; + slist_member_hook_t slist_node_; + slist_auto_member_hook_t slist_auto_node_; int value_; @@ -101,24 +88,24 @@ struct testvalue testvalue & operator= (const testvalue& src) { - set_base_hook::operator=(src); + set_base_hook_t::operator=(src); this->set_node_ = src.set_node_; - set_auto_base_hook::operator=(src); + set_auto_base_hook_t::operator=(src); this->set_auto_node_ = src.set_auto_node_; - unordered_set_base_hook::operator=(src); + unordered_set_base_hook_t::operator=(src); this->unordered_set_node_ = src.unordered_set_node_; - unordered_set_auto_base_hook::operator=(src); + unordered_set_auto_base_hook_t::operator=(src); this->unordered_set_auto_node_ = src.unordered_set_auto_node_; - list_base_hook::operator=(src); + list_base_hook_t::operator=(src); this->list_node_ = src.list_node_; - list_auto_base_hook::operator=(src); + list_auto_base_hook_t::operator=(src); this->list_auto_node_ = src.list_auto_node_; - slist_base_hook::operator=(src); + slist_base_hook_t::operator=(src); this->slist_node_ = src.slist_node_; - slist_auto_base_hook::operator=(src); + slist_auto_base_hook_t::operator=(src); this->slist_auto_node_ = src.slist_auto_node_; value_ = src.value_; return *this; @@ -131,15 +118,15 @@ struct testvalue //... //List - list_base_hook::swap_nodes(other); + list_base_hook_t::swap_nodes(other); list_node_.swap_nodes(other.list_node_); - list_auto_base_hook::swap_nodes(other); + list_auto_base_hook_t::swap_nodes(other); list_auto_node_.swap_nodes(other.list_auto_node_); //Slist - slist_base_hook::swap_nodes(other); + slist_base_hook_t::swap_nodes(other); slist_node_.swap_nodes(other.slist_node_); - slist_auto_base_hook::swap_nodes(other); + slist_auto_base_hook_t::swap_nodes(other); slist_auto_node_.swap_nodes(other.slist_auto_node_); } @@ -151,6 +138,18 @@ struct testvalue bool operator==(const testvalue &other) const { return value_ == other.value_; } + + friend bool operator< (int other1, const testvalue &other2) + { return other1 < other2.value_; } + + friend bool operator< (const testvalue &other1, int other2) + { return other1.value_ < other2; } + + friend bool operator== (int other1, const testvalue &other2) + { return other1 == other2.value_; } + + friend bool operator== (const testvalue &other1, int other2) + { return other1.value_ == other2; } }; template @@ -185,151 +184,151 @@ typedef testvalue value_r_t; typedef testvalue, true> value_s_t; //Typedefs -typedef value_r_f::set_base_hook:: +typedef value_r_f::set_base_hook_t:: value_traits set_base_raw; -typedef value_r_f::set_member_hook:: +typedef value_r_f::set_member_hook_t:: value_traits set_member_raw; -typedef value_r_f::set_auto_base_hook:: +typedef value_r_f::set_auto_base_hook_t:: value_traits set_auto_base_raw; -typedef value_r_f::set_auto_member_hook:: +typedef value_r_f::set_auto_member_hook_t:: value_traits set_auto_member_raw; -typedef value_s_f::set_base_hook:: +typedef value_s_f::set_base_hook_t:: value_traits set_base_smart; -typedef value_s_f::set_member_hook:: +typedef value_s_f::set_member_hook_t:: value_traits set_member_smart; -typedef value_s_f::set_auto_base_hook:: +typedef value_s_f::set_auto_base_hook_t:: value_traits set_auto_base_smart; -typedef value_s_f::set_auto_member_hook:: +typedef value_s_f::set_auto_member_hook_t:: value_traits set_auto_member_smart; -typedef value_r_t::set_base_hook:: +typedef value_r_t::set_base_hook_t:: value_traits set_base_raw_t; -typedef value_r_t::set_member_hook:: +typedef value_r_t::set_member_hook_t:: value_traits set_member_raw_t; -typedef value_s_t::set_base_hook:: +typedef value_s_t::set_base_hook_t:: value_traits set_base_smart_t; -typedef value_s_t::set_member_hook:: +typedef value_s_t::set_member_hook_t:: value_traits set_member_smart_t; //Typedefs -typedef value_r_f::unordered_set_base_hook:: +typedef value_r_f::unordered_set_base_hook_t:: value_traits unordered_set_base_raw; -typedef value_r_f::unordered_set_member_hook:: +typedef value_r_f::unordered_set_member_hook_t:: value_traits unordered_set_member_raw; -typedef value_r_f::unordered_set_auto_base_hook:: +typedef value_r_f::unordered_set_auto_base_hook_t:: value_traits unordered_set_auto_base_raw; -typedef value_r_f::unordered_set_auto_member_hook:: +typedef value_r_f::unordered_set_auto_member_hook_t:: value_traits unordered_set_auto_member_raw; -typedef value_s_f::unordered_set_base_hook:: +typedef value_s_f::unordered_set_base_hook_t:: value_traits unordered_set_base_smart; -typedef value_s_f::unordered_set_member_hook:: +typedef value_s_f::unordered_set_member_hook_t:: value_traits unordered_set_member_smart; -typedef value_s_f::unordered_set_auto_base_hook:: +typedef value_s_f::unordered_set_auto_base_hook_t:: value_traits unordered_set_auto_base_smart; -typedef value_s_f::unordered_set_auto_member_hook:: +typedef value_s_f::unordered_set_auto_member_hook_t:: value_traits unordered_set_auto_member_smart; -typedef value_r_t::unordered_set_base_hook:: +typedef value_r_t::unordered_set_base_hook_t:: value_traits unordered_set_base_raw_t; -typedef value_r_t::unordered_set_member_hook:: +typedef value_r_t::unordered_set_member_hook_t:: value_traits unordered_set_member_raw_t; -typedef value_s_t::unordered_set_base_hook:: +typedef value_s_t::unordered_set_base_hook_t:: value_traits unordered_set_base_smart_t; -typedef value_s_t::unordered_set_member_hook:: +typedef value_s_t::unordered_set_member_hook_t:: value_traits unordered_set_member_smart_t; //Explicit instantiations -typedef value_r_f::list_base_hook:: +typedef value_r_f::list_base_hook_t:: value_traits list_base_raw; -typedef value_r_f::list_member_hook:: +typedef value_r_f::list_member_hook_t:: value_traits list_member_raw; -typedef value_r_f::list_auto_base_hook:: +typedef value_r_f::list_auto_base_hook_t:: value_traits list_auto_base_raw; -typedef value_r_f::list_auto_member_hook:: +typedef value_r_f::list_auto_member_hook_t:: value_traits list_auto_member_raw; -typedef value_s_f::list_base_hook:: +typedef value_s_f::list_base_hook_t:: value_traits list_base_smart; -typedef value_s_f::list_member_hook:: +typedef value_s_f::list_member_hook_t:: value_traits list_member_smart; -typedef value_s_f::list_auto_base_hook:: +typedef value_s_f::list_auto_base_hook_t:: value_traits list_auto_base_smart; -typedef value_s_f::list_auto_member_hook:: +typedef value_s_f::list_auto_member_hook_t:: value_traits list_auto_member_smart; -typedef value_r_t::list_base_hook:: +typedef value_r_t::list_base_hook_t:: value_traits list_base_raw_t; -typedef value_r_t::list_member_hook:: +typedef value_r_t::list_member_hook_t:: value_traits list_member_raw_t; -typedef value_s_t::list_base_hook:: +typedef value_s_t::list_base_hook_t:: value_traits list_base_smart_t; -typedef value_s_t::list_member_hook:: +typedef value_s_t::list_member_hook_t:: value_traits list_member_smart_t; -typedef value_r_f::slist_base_hook:: +typedef value_r_f::slist_base_hook_t:: value_traits slist_base_raw; -typedef value_r_f::slist_member_hook:: +typedef value_r_f::slist_member_hook_t:: value_traits slist_member_raw; -typedef value_r_f::slist_auto_base_hook:: +typedef value_r_f::slist_auto_base_hook_t:: value_traits slist_auto_base_raw; -typedef value_r_f::slist_auto_member_hook:: +typedef value_r_f::slist_auto_member_hook_t:: value_traits slist_auto_member_raw; -typedef value_s_f::slist_base_hook:: +typedef value_s_f::slist_base_hook_t:: value_traits slist_base_smart; -typedef value_s_f::slist_member_hook:: +typedef value_s_f::slist_member_hook_t:: value_traits slist_member_smart; -typedef value_s_f::slist_auto_base_hook:: +typedef value_s_f::slist_auto_base_hook_t:: value_traits slist_auto_base_smart; -typedef value_s_f::slist_auto_member_hook:: +typedef value_s_f::slist_auto_member_hook_t:: value_traits slist_auto_member_smart; -typedef value_r_t::slist_base_hook:: +typedef value_r_t::slist_base_hook_t:: value_traits slist_base_raw_t; -typedef value_r_t::slist_member_hook:: +typedef value_r_t::slist_member_hook_t:: value_traits slist_member_raw_t; -typedef value_s_t::slist_base_hook:: +typedef value_s_t::slist_base_hook_t:: value_traits slist_base_smart_t; -typedef value_s_t::slist_member_hook:: +typedef value_s_t::slist_member_hook_t:: value_traits slist_member_smart_t; } //namespace boost{ diff --git a/test/list_test.cpp b/test/list_test.cpp index 7e7ad03..096c0a1 100644 --- a/test/list_test.cpp +++ b/test/list_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztaņaga 2006-2007. +// (C) Copyright Ion Gaztanaga 2006-2007. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -16,10 +16,8 @@ #include "smart_ptr.hpp" #include "common_functors.hpp" #include -#include - -// Boost.Test -#include "boost/test/included/test_exec_monitor.hpp" +#include +#include "test_macros.hpp" using namespace boost::intrusive; @@ -66,26 +64,26 @@ void test_list , std::size_t > list_type; list_type testlist; - BOOST_CHECK (testlist.empty()); + BOOST_TEST (testlist.empty()); testlist.push_back (values[0]); - BOOST_CHECK (testlist.size() == 1); - BOOST_CHECK (&testlist.front() == &values[0]); - BOOST_CHECK (&testlist.back() == &values[0]); + BOOST_TEST (testlist.size() == 1); + BOOST_TEST (&testlist.front() == &values[0]); + BOOST_TEST (&testlist.back() == &values[0]); testlist.push_front (values[1]); - BOOST_CHECK (testlist.size() == 2); - BOOST_CHECK (&testlist.front() == &values[1]); - BOOST_CHECK (&testlist.back() == &values[0]); + BOOST_TEST (testlist.size() == 2); + BOOST_TEST (&testlist.front() == &values[1]); + BOOST_TEST (&testlist.back() == &values[0]); testlist.pop_back(); - BOOST_CHECK (testlist.size() == 1); + BOOST_TEST (testlist.size() == 1); const list_type &const_testlist = testlist; - BOOST_CHECK (&const_testlist.front() == &values[1]); - BOOST_CHECK (&const_testlist.back() == &values[1]); + BOOST_TEST (&const_testlist.front() == &values[1]); + BOOST_TEST (&const_testlist.back() == &values[1]); testlist.pop_front(); - BOOST_CHECK (testlist.empty()); + BOOST_TEST (testlist.empty()); } @@ -95,7 +93,7 @@ void test_list ::test_sort(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; + std::vector expected; typedef boost::intrusive::list < ValueTraits , ValueTraits::value_type::constant_time_size @@ -103,22 +101,17 @@ void test_list > list_type; list_type testlist(values.begin(), values.end()); - std::copy (testlist.begin(), testlist.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("12345")); + { int init_values [] = { 1, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); } testlist.sort (even_odd()); - std::copy (testlist.rbegin(), testlist.rend(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("53142")); + { int init_values [] = { 5, 3, 1, 4, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist.rbegin() ); } testlist.reverse(); - //test postincrement: - for (BOOST_DEDUCED_TYPENAME list_type::iterator i = - testlist.begin(), e = testlist.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("53142")); -} + { int init_values [] = { 5, 3, 1, 4, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); } +} //test: assign, insert, const_iterator, const_reverse_iterator, erase, iterator_to: template @@ -126,7 +119,7 @@ void test_list ::test_insert(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; + std::vector expected; typedef boost::intrusive::list < ValueTraits , ValueTraits::value_type::constant_time_size @@ -136,29 +129,29 @@ void test_list testlist.assign (&values[0] + 2, &values[0] + 5); const list_type& const_testlist = testlist; - std::copy (const_testlist.begin(), const_testlist.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("345")); + { int init_values [] = { 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } - BOOST_DEDUCED_TYPENAME list_type::iterator i = ++testlist.begin(); - BOOST_CHECK (i->value_ == 4); + typename list_type::iterator i = ++testlist.begin(); + BOOST_TEST (i->value_ == 4); + + { + typename list_type::const_iterator ci = typename list_type::iterator(); + //typename list_type::iterator i = typename list_type::const_iterator(); + } testlist.insert (i, values[0]); - std::copy (const_testlist.rbegin(), const_testlist.rend(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("5413")); + { int init_values [] = { 5, 4, 1, 3 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.rbegin() ); } i = testlist.iterator_to (values[4]); - BOOST_CHECK (&*i == &values[4]); + BOOST_TEST (&*i == &values[4]); i = testlist.erase (i); - BOOST_CHECK (i == testlist.end()); + BOOST_TEST (i == testlist.end()); - //test postincrement: - for (BOOST_DEDUCED_TYPENAME list_type::const_iterator i = - const_testlist.begin(), e = const_testlist.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("314")); + { int init_values [] = { 3, 1, 4 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } } template @@ -166,13 +159,13 @@ void test_list ::test_shift(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::list < ValueTraits , ValueTraits::value_type::constant_time_size , std::size_t > list_type; list_type testlist; + std::vector expected; const int num_values = (int)values.size(); std::vector expected_values(num_values); @@ -184,13 +177,7 @@ void test_list for(int j = 0; j < num_values; ++j){ expected_values[(j + num_values - i%num_values) % num_values] = (j + 1); } - std::copy (testlist.begin(), testlist.end(), - std::ostream_iterator (test_seq)); - std::stringstream stream; - std::copy (expected_values.begin(), expected_values.end(), - std::ostream_iterator (stream)); - stream << std::ends; - BOOST_CHECK (test_seq.is_equal (stream.str().c_str())); + TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin()); testlist.clear(); } @@ -201,13 +188,7 @@ void test_list for(int j = 0; j < num_values; ++j){ expected_values[(j + i) % num_values] = (j + 1); } - std::copy (testlist.begin(), testlist.end(), - std::ostream_iterator (test_seq)); - std::stringstream stream; - std::copy (expected_values.begin(), expected_values.end(), - std::ostream_iterator (stream)); - stream << std::ends; - BOOST_CHECK (test_seq.is_equal (stream.str().c_str())); + TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin()); testlist.clear(); } } @@ -218,68 +199,59 @@ void test_list ::test_swap(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::list list_type; - + std::vector expected; { list_type testlist1 (&values[0], &values[0] + 2); list_type testlist2; testlist2.insert (testlist2.end(), &values[0] + 2, &values[0] + 5); testlist1.swap (testlist2); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("345")); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("12")); + + { int init_values [] = { 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } + { int init_values [] = { 1, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } testlist2.splice (++testlist2.begin(), testlist1); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("13452")); - BOOST_CHECK (testlist1.empty()); + { int init_values [] = { 1, 3, 4, 5, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } + + BOOST_TEST (testlist1.empty()); testlist1.splice (testlist1.end(), testlist2, ++(++testlist2.begin())); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("4")); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("1352")); + { int init_values [] = { 4 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } + + { int init_values [] = { 1, 3, 5, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } testlist1.splice (testlist1.end(), testlist2, testlist2.begin(), ----testlist2.end()); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("413")); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("52")); + { int init_values [] = { 4, 1, 3 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } + { int init_values [] = { 5, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } testlist1.erase (testlist1.iterator_to(values[0]), testlist1.end()); - BOOST_CHECK (testlist1.size() == 1); - BOOST_CHECK (&testlist1.front() == &values[3]); + BOOST_TEST (testlist1.size() == 1); + BOOST_TEST (&testlist1.front() == &values[3]); } { - boost::test_tools::output_test_stream test_seq; list_type testlist1 (&values[0], &values[0] + 2); list_type testlist2 (&values[0] + 3, &values[0] + 5); values[0].swap_nodes(values[2]); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("32")); + { int init_values [] = { 3, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } values[2].swap_nodes(values[4]); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("52")); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("43")); + { int init_values [] = { 5, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } + { int init_values [] = { 4, 3 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } } } @@ -288,7 +260,7 @@ void test_list ::test_clone(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; + std::vector expected; typedef boost::intrusive::list list_type testlist2; testlist2.clone_from(testlist1, test::new_cloner(), test::delete_destroyer()); - BOOST_CHECK (testlist2 == testlist1); + BOOST_TEST (testlist2 == testlist1); testlist2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testlist2.empty()); + BOOST_TEST (testlist2.empty()); } template @@ -314,10 +286,10 @@ class test_main_template for (int i = 0; i < 5; ++i) data[i].value_ = i + 1; - test_list >::test_all(data); - test_list >::test_all(data); return 0; @@ -335,21 +307,21 @@ class test_main_template for (int i = 0; i < 5; ++i) data[i].value_ = i + 1; - test_list >::test_all(data); - test_list >::test_all(data); - test_list >::test_all(data); - test_list >::test_all(data); return 0; } }; - +/* //Explicit instantiations of non-counted classes template class boost::intrusive::list; template class boost::intrusive::list; @@ -365,12 +337,12 @@ template class boost::intrusive::list; template class boost::intrusive::list; template class boost::intrusive::list; template class boost::intrusive::list; - -int test_main( int, char* [] ) +*/ +int main( int, char* [] ) { test_main_template()(); test_main_template, false>()(); test_main_template()(); test_main_template, true>()(); - return 0; + return boost::report_errors(); } diff --git a/test/multiset_test.cpp b/test/multiset_test.cpp index ce4367f..517b672 100644 --- a/test/multiset_test.cpp +++ b/test/multiset_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztaņaga 2006-2007. +// (C) Copyright Ion Gaztanaga 2006-2007. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -16,11 +16,9 @@ #include "itestvalue.hpp" #include "smart_ptr.hpp" #include "common_functors.hpp" - #include - -// Boost.Test -#include "boost/test/included/test_exec_monitor.hpp" +#include +#include "test_macros.hpp" using namespace boost::intrusive; @@ -78,21 +76,17 @@ template void test_multiset::test_sort(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef multiset ,ValueTraits::value_type::constant_time_size, std::size_t > multiset_type; multiset_type testset1 (values.begin(), values.end()); + { int init_values [] = { 1, 2, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("122345")); - testset1.clear(); - BOOST_CHECK (testset1.empty()); + BOOST_TEST (testset1.empty()); typedef multiset ::test_sort(std::vector multiset_type2; multiset_type2 testset2 (&values[0], &values[0] + 6); - std::copy (testset2.rbegin(), testset2.rend(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("531422")); - BOOST_CHECK (testset2.begin()->value_ == 2); - BOOST_CHECK (testset2.rbegin()->value_ == 5); + { int init_values [] = { 5, 3, 1, 4, 2, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset2.rbegin() ); } + + BOOST_TEST (testset2.begin()->value_ == 2); + BOOST_TEST (testset2.rbegin()->value_ == 5); } //test: insert, const_iterator, const_reverse_iterator, erase, iterator_to: @@ -112,8 +106,6 @@ template void test_multiset::test_insert(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef multiset @@ -122,31 +114,24 @@ void test_multiset::test_insert(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("145")); - - BOOST_DEDUCED_TYPENAME multiset_type::iterator i = testset.begin(); - BOOST_CHECK (i->value_ == 1); + typename multiset_type::iterator i = testset.begin(); + BOOST_TEST (i->value_ == 1); i = testset.insert (i, values[0]); - BOOST_CHECK (&*i == &values[0]); - - std::copy (const_testset.rbegin(), const_testset.rend(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("5431")); + BOOST_TEST (&*i == &values[0]); + + { int init_values [] = { 5, 4, 3, 1 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset.rbegin() ); } i = testset.iterator_to (values[2]); - BOOST_CHECK (&*i == &values[2]); + BOOST_TEST (&*i == &values[2]); testset.erase(i); - //test post-increment: - for (BOOST_DEDUCED_TYPENAME multiset_type::const_iterator i = const_testset.begin(), - e = const_testset.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("135")); + { int init_values [] = { 1, 3, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset.begin() ); } } //test: insert (seq-version), swap, erase (seq-version), size: @@ -154,7 +139,6 @@ template void test_multiset::test_swap(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef multiset @@ -164,19 +148,15 @@ void test_multiset::test_swap(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("1245")); - //test post-increment: - for (BOOST_DEDUCED_TYPENAME multiset_type::iterator i = testset2.begin(), - e = testset2.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("23")); + + { int init_values [] = { 1, 2, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } + { int init_values [] = { 2, 3 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); } testset1.erase (testset1.iterator_to(values[5]), testset1.end()); - BOOST_CHECK (testset1.size() == 1); - BOOST_CHECK (&*testset1.begin() == &values[3]); + BOOST_TEST (testset1.size() == 1); + BOOST_TEST (&*testset1.begin() == &values[3]); } //test: find, equal_range (lower_bound, upper_bound): @@ -184,28 +164,27 @@ template void test_multiset::test_find(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef multiset ,ValueTraits::value_type::constant_time_size, std::size_t > multiset_type; multiset_type testset (values.begin(), values.end()); - typedef BOOST_DEDUCED_TYPENAME multiset_type::iterator iterator; + typedef typename multiset_type::iterator iterator; testvalue_t cmp_val; cmp_val.value_ = 2; iterator i = testset.find (cmp_val); - BOOST_CHECK (i->value_ == 2); - BOOST_CHECK ((++i)->value_ == 2); + BOOST_TEST (i->value_ == 2); + BOOST_TEST ((++i)->value_ == 2); std::pair range = testset.equal_range (cmp_val); - BOOST_CHECK (range.first->value_ == 2); - BOOST_CHECK (range.second->value_ == 3); - BOOST_CHECK (std::distance (range.first, range.second) == 2); + BOOST_TEST (range.first->value_ == 2); + BOOST_TEST (range.second->value_ == 3); + BOOST_TEST (std::distance (range.first, range.second) == 2); cmp_val.value_ = 7; - BOOST_CHECK (testset.find (cmp_val) == testset.end()); + BOOST_TEST (testset.find (cmp_val) == testset.end()); } template @@ -223,9 +202,9 @@ void test_multiset multiset_type testmultiset2; testmultiset2.clone_from(testmultiset1, test::new_cloner(), test::delete_destroyer()); - BOOST_CHECK (testmultiset2 == testmultiset1); + BOOST_TEST (testmultiset2 == testmultiset1); testmultiset2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testmultiset2.empty()); + BOOST_TEST (testmultiset2.empty()); } template @@ -240,10 +219,10 @@ class test_main_template for (int i = 0; i < 6; ++i) data[i].value_ = random_init[i]; - test_multiset >::test_all(data); - test_multiset >::test_all(data); return 0; @@ -262,21 +241,21 @@ class test_main_template for (int i = 0; i < 6; ++i) data[i].value_ = random_init[i]; - test_multiset >::test_all(data); - test_multiset >::test_all(data); - test_multiset >::test_all(data); - test_multiset >::test_all(data); return 0; } }; - +/* //Explicit instantiations of non-counted classes template class multiset , false>; @@ -304,14 +283,14 @@ template class multiset , true>; template class multiset , true>; - -int test_main( int, char* [] ) +*/ +int main( int, char* [] ) { test_main_template()(); test_main_template, false>()(); test_main_template()(); test_main_template, true>()(); - return 0; + return boost::report_errors(); } diff --git a/test/set_test.cpp b/test/set_test.cpp index cdea5df..f9d2393 100644 --- a/test/set_test.cpp +++ b/test/set_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztaņaga 2006-2007. +// (C) Copyright Ion Gaztanaga 2006-2007. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -17,9 +17,8 @@ #include "smart_ptr.hpp" #include "common_functors.hpp" #include - -// Boost.Test -#include "boost/test/included/test_exec_monitor.hpp" +#include +#include "test_macros.hpp" using namespace boost::intrusive; @@ -78,20 +77,17 @@ template void test_set::test_sort(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::set ,ValueTraits::value_type::constant_time_size, std::size_t > set_type; set_type testset1 (values.begin(), values.end()); + { int init_values [] = { 1, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("12345")); - testset1.clear(); - BOOST_CHECK (testset1.empty()); + BOOST_TEST (testset1.empty()); typedef boost::intrusive::set ::test_sort(std::vector set_type2; set_type2 testset2 (&values[0], &values[0] + 6); - std::copy (testset2.rbegin(), testset2.rend(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("53142")); - BOOST_CHECK (testset2.begin()->value_ == 2); - BOOST_CHECK (testset2.rbegin()->value_ == 5); + { int init_values [] = { 5, 3, 1, 4, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset2.rbegin() ); } + BOOST_TEST (testset2.begin()->value_ == 2); + BOOST_TEST (testset2.rbegin()->value_ == 5); } //test: insert, const_iterator, const_reverse_iterator, erase, iterator_to: @@ -111,7 +106,6 @@ template void test_set::test_insert(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::set @@ -121,29 +115,24 @@ void test_set::test_insert(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("145")); + { int init_values [] = { 1, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); } - BOOST_DEDUCED_TYPENAME set_type::iterator i = testset.begin(); - BOOST_CHECK (i->value_ == 1); + typename set_type::iterator i = testset.begin(); + BOOST_TEST (i->value_ == 1); i = testset.insert (i, values[0]); - BOOST_CHECK (&*i == &values[0]); - - std::copy (const_testset.rbegin(), const_testset.rend(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("5431")); + BOOST_TEST (&*i == &values[0]); + + { int init_values [] = { 5, 4, 3, 1 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset.rbegin() ); } i = testset.iterator_to (values[2]); - BOOST_CHECK (&*i == &values[2]); + BOOST_TEST (&*i == &values[2]); testset.erase (i); - //test post-increment: - for (BOOST_DEDUCED_TYPENAME set_type::const_iterator i = const_testset.begin(), - e = const_testset.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("135")); + { int init_values [] = { 1, 3, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset.begin() ); } } //test: insert (seq-version), swap, erase (seq-version), size: @@ -151,8 +140,6 @@ template void test_set::test_swap(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef boost::intrusive::set @@ -162,20 +149,17 @@ void test_set::test_swap(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("1245")); - //test post-increment: - for (BOOST_DEDUCED_TYPENAME set_type::iterator i = testset2.begin(), - e = testset2.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("23")); + + { int init_values [] = { 1, 2, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } + + { int init_values [] = { 2, 3 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); } testset1.erase (testset1.iterator_to(values[5]), testset1.end()); - BOOST_CHECK (testset1.size() == 1); - // BOOST_CHECK (&testset1.front() == &values[3]); - BOOST_CHECK (&*testset1.begin() == &values[3]); + BOOST_TEST (testset1.size() == 1); + // BOOST_TEST (&testset1.front() == &values[3]); + BOOST_TEST (&*testset1.begin() == &values[3]); } //test: find, equal_range (lower_bound, upper_bound): @@ -183,29 +167,27 @@ template void test_set::test_find(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef boost::intrusive::set ,ValueTraits::value_type::constant_time_size, std::size_t > set_type; set_type testset (values.begin(), values.end()); - typedef BOOST_DEDUCED_TYPENAME set_type::iterator iterator; + typedef typename set_type::iterator iterator; testvalue_t cmp_val; cmp_val.value_ = 2; iterator i = testset.find (cmp_val); - BOOST_CHECK (i->value_ == 2); - BOOST_CHECK ((++i)->value_ != 2); + BOOST_TEST (i->value_ == 2); + BOOST_TEST ((++i)->value_ != 2); std::pair range = testset.equal_range (cmp_val); - BOOST_CHECK (range.first->value_ == 2); - BOOST_CHECK (range.second->value_ == 3); - BOOST_CHECK (std::distance (range.first, range.second) == 1); + BOOST_TEST (range.first->value_ == 2); + BOOST_TEST (range.second->value_ == 3); + BOOST_TEST (std::distance (range.first, range.second) == 1); cmp_val.value_ = 7; - BOOST_CHECK (testset.find (cmp_val) == testset.end()); + BOOST_TEST (testset.find (cmp_val) == testset.end()); } template @@ -223,9 +205,9 @@ void test_set set_type testset2; testset2.clone_from(testset1, test::new_cloner(), test::delete_destroyer()); - BOOST_CHECK (testset2 == testset1); + BOOST_TEST (testset2 == testset1); testset2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testset2.empty()); + BOOST_TEST (testset2.empty()); } template @@ -240,10 +222,10 @@ class test_main_template for (int i = 0; i < 6; ++i) data[i].value_ = random_init[i]; - test_set >::test_all(data); - test_set >::test_all(data); return 0; @@ -262,21 +244,21 @@ class test_main_template for (int i = 0; i < 6; ++i) data[i].value_ = random_init[i]; - test_set >::test_all(data); - test_set >::test_all(data); - test_set >::test_all(data); - test_set >::test_all(data); return 0; } }; - +/* //Explicit instantiations of non-counted classes template class boost::intrusive::set , false>; @@ -304,12 +286,12 @@ template class boost::intrusive::set , true>; template class boost::intrusive::set , true>; - -int test_main( int, char* [] ) +*/ +int main( int, char* [] ) { test_main_template()(); test_main_template, false>()(); test_main_template()(); test_main_template, true>()(); - return 0; + return boost::report_errors(); } diff --git a/test/slist_test.cpp b/test/slist_test.cpp index 5fae54d..440176d 100644 --- a/test/slist_test.cpp +++ b/test/slist_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztaņaga 2006-2007. +// (C) Copyright Ion Gaztanaga 2006-2007. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -16,10 +16,8 @@ #include "smart_ptr.hpp" #include "common_functors.hpp" #include -#include - -// Boost.Test -#include "boost/test/included/test_exec_monitor.hpp" +#include +#include "test_macros.hpp" using namespace boost::intrusive; @@ -62,22 +60,22 @@ void test_slist ,ValueTraits::value_type::constant_time_size, std::size_t > list_type; list_type testlist; - BOOST_CHECK (testlist.empty()); + BOOST_TEST (testlist.empty()); testlist.push_front (values[0]); - BOOST_CHECK (testlist.size() == 1); - BOOST_CHECK (&testlist.front() == &values[0]); + BOOST_TEST (testlist.size() == 1); + BOOST_TEST (&testlist.front() == &values[0]); testlist.push_front (values[1]); - BOOST_CHECK (testlist.size() == 2); - BOOST_CHECK (&testlist.front() == &values[1]); + BOOST_TEST (testlist.size() == 2); + BOOST_TEST (&testlist.front() == &values[1]); testlist.pop_front(); - BOOST_CHECK (testlist.size() == 1); - BOOST_CHECK (&testlist.front() == &values[0]); + BOOST_TEST (testlist.size() == 1); + BOOST_TEST (&testlist.front() == &values[0]); testlist.pop_front(); - BOOST_CHECK (testlist.empty()); + BOOST_TEST (testlist.empty()); } //test: merge due to error in merge implementation: @@ -86,7 +84,6 @@ void test_slist ::test_merge (std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::slist testlist2.push_front (values[2]); testlist1.merge (testlist2); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("1345")); + int init_values [] = { 1, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } //test: constructor, iterator, sort, reverse: @@ -109,27 +105,22 @@ void test_slist ::test_sort(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::slist list_type; list_type testlist (values.begin(), values.end()); - std::copy (testlist.begin(), testlist.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("12345")); - + { int init_values [] = { 1, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); } + testlist.sort (even_odd()); - for (BOOST_DEDUCED_TYPENAME list_type::iterator i = testlist.begin(), - e = testlist.end(); i != e; i++) //test postincrement - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("24135")); + { int init_values [] = { 2, 4, 1, 3, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); } testlist.reverse(); - std::copy (testlist.begin(), testlist.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("53142")); + { int init_values [] = { 5, 3, 1, 4, 2, }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist.begin() ); } } //test: assign, insert_after, const_iterator, erase_after, iterator_to, previous: @@ -138,7 +129,6 @@ void test_slist ::test_insert(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::slist testlist.assign (&values[0] + 2, &values[0] + 5); const list_type& const_testlist = testlist; - std::copy (const_testlist.begin(), const_testlist.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("345")); + { int init_values [] = { 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } - BOOST_DEDUCED_TYPENAME list_type::iterator i = ++testlist.begin(); - BOOST_CHECK (i->value_ == 4); + typename list_type::iterator i = ++testlist.begin(); + BOOST_TEST (i->value_ == 4); testlist.insert_after (i, values[0]); - for (BOOST_DEDUCED_TYPENAME list_type::const_iterator i2 = const_testlist.begin(), - e = const_testlist.end(); i2 != e; i2++) //test postincrement - test_seq << *i2; - BOOST_CHECK (test_seq.is_equal ("3415")); + { int init_values [] = { 3, 4, 1, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } i = testlist.iterator_to (values[4]); - BOOST_CHECK (&*i == &values[4]); + BOOST_TEST (&*i == &values[4]); i = testlist.previous (i); - BOOST_CHECK (&*i == &values[0]); + BOOST_TEST (&*i == &values[0]); testlist.erase_after (i); - BOOST_CHECK (&*i == &values[0]); - - std::copy (const_testlist.begin(), const_testlist.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("341")); -} + BOOST_TEST (&*i == &values[0]); + { int init_values [] = { 3, 4, 1 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } +} //test: insert, const_iterator, erase, iterator_to: template @@ -179,7 +164,6 @@ void test_slist ::test_slow_insert (std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::slist testlist.insert (testlist.begin(), &values[0] + 2, &values[0] + 4); const list_type& const_testlist = testlist; - std::copy (const_testlist.begin(), const_testlist.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("345")); + { int init_values [] = { 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } - BOOST_DEDUCED_TYPENAME list_type::iterator i = ++testlist.begin(); - BOOST_CHECK (i->value_ == 4); + typename list_type::iterator i = ++testlist.begin(); + BOOST_TEST (i->value_ == 4); testlist.insert (i, values[0]); - std::copy (const_testlist.begin(), const_testlist.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("3145")); + { int init_values [] = { 3, 1, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } i = testlist.iterator_to (values[4]); - BOOST_CHECK (&*i == &values[4]); + BOOST_TEST (&*i == &values[4]); i = testlist.erase (i); - BOOST_CHECK (i == testlist.end()); + BOOST_TEST (i == testlist.end()); + + { int init_values [] = { 3, 1, 4 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testlist.begin() ); } - //test postincrement: - for (BOOST_DEDUCED_TYPENAME list_type::const_iterator i = - const_testlist.begin(), e = const_testlist.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("314")); testlist.erase (++testlist.begin(), testlist.end()); - BOOST_CHECK (testlist.size() == 1); - BOOST_CHECK (testlist.front().value_ == 3); + BOOST_TEST (testlist.size() == 1); + BOOST_TEST (testlist.front().value_ == 3); } template @@ -222,7 +202,6 @@ void test_slist ::test_shift(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::slist for(int j = 0; j < num_values; ++j){ expected_values[(j + num_values - i%num_values) % num_values] = (j + 1); } - std::copy (testlist.begin(), testlist.end(), - std::ostream_iterator (test_seq)); - std::stringstream stream; - std::copy (expected_values.begin(), expected_values.end(), - std::ostream_iterator (stream)); - stream << std::ends; - BOOST_CHECK (test_seq.is_equal (stream.str().c_str())); + + TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin()) testlist.clear(); } @@ -256,19 +230,8 @@ void test_slist for(int j = 0; j < num_values; ++j){ expected_values[(j + i) % num_values] = (j + 1); } - std::copy (testlist.begin(), testlist.end(), - std::ostream_iterator (test_seq)); - std::stringstream stream2; - std::copy (testlist.begin(), testlist.end(), - std::ostream_iterator (stream2)); - stream2 << std::ends; - - std::stringstream stream; - std::copy (expected_values.begin(), expected_values.end(), - std::ostream_iterator (stream)); - stream << std::ends; - BOOST_CHECK (test_seq.is_equal (stream.str().c_str())); + TEST_INTRUSIVE_SEQUENCE_EXPECTED(expected_values, testlist.begin()) testlist.clear(); } } @@ -279,7 +242,6 @@ void test_slist ::test_swap(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::slist list_type testlist2; testlist2.insert_after (testlist2.end(), &values[0] + 2, &values[0] + 5); testlist1.swap(testlist2); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("345")); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("12")); - - testlist2.splice_after (testlist2.begin(), testlist1); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("13452")); - BOOST_CHECK (testlist1.empty()); + { int init_values [] = { 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } + { int init_values [] = { 1, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } + testlist2.splice_after (testlist2.begin(), testlist1); + { int init_values [] = { 1, 3, 4, 5, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } + BOOST_TEST (testlist1.empty()); testlist1.splice_after (testlist1.end(), testlist2, ++testlist2.begin()); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("4")); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("1352")); + { int init_values [] = { 4 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } + { int init_values [] = { 1, 3, 5, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } testlist1.splice_after (testlist1.begin(), testlist2, testlist2.end(), ++++testlist2.begin()); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("4135")); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("2")); + { int init_values [] = { 4, 1, 3, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } + { int init_values [] = { 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } } { - boost::test_tools::output_test_stream test_seq; - list_type testlist1 (&values[0], &values[0] + 2); list_type testlist2 (&values[0] + 3, &values[0] + 5); values[0].swap_nodes(values[2]); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("32")); + { int init_values [] = { 3, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } values[2].swap_nodes(values[4]); - std::copy (testlist1.begin(), testlist1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("52")); - std::copy (testlist2.begin(), testlist2.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("43")); + { int init_values [] = { 5, 2 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); } + { int init_values [] = { 4, 3 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); } } } @@ -345,7 +294,6 @@ void test_slist ::test_clone(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::slist list_type testlist2; testlist2.clone_from(testlist1, test::new_cloner(), test::delete_destroyer()); - BOOST_CHECK (testlist2 == testlist1); + BOOST_TEST (testlist2 == testlist1); testlist2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testlist2.empty()); + BOOST_TEST (testlist2.empty()); } template @@ -371,10 +319,10 @@ class test_main_template for (int i = 0; i < 5; ++i) data[i].value_ = i + 1; - test_slist >::test_all(data); - test_slist >::test_all(data); return 0; @@ -392,21 +340,21 @@ class test_main_template for (int i = 0; i < 5; ++i) data[i].value_ = i + 1; - test_slist >::test_all(data); - test_slist >::test_all(data); - test_slist >::test_all(data); - test_slist >::test_all(data); return 0; } }; - +/* //Explicit instantiations of non-counted classes template class boost::intrusive::slist; template class boost::intrusive::slist; @@ -422,12 +370,12 @@ template class boost::intrusive::slist; template class boost::intrusive::slist; template class boost::intrusive::slist; template class boost::intrusive::slist; - -int test_main(int, char* []) +*/ +int main(int, char* []) { test_main_template()(); test_main_template, false>()(); test_main_template()(); test_main_template, true>()(); - return 0; + return boost::report_errors(); } diff --git a/test/smart_ptr.hpp b/test/smart_ptr.hpp index 98a63d1..cb4d831 100644 --- a/test/smart_ptr.hpp +++ b/test/smart_ptr.hpp @@ -1,6 +1,6 @@ ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztaņaga 2006. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2006. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // @@ -43,44 +43,36 @@ struct random_it template<> struct random_it { - typedef void * pointer; typedef const void * const_pointer; typedef empty_type& reference; typedef const empty_type& const_reference; - typedef void value_type; typedef empty_type difference_type; typedef empty_type iterator_category; }; template<> struct random_it { - typedef const void * pointer; typedef const void * const_pointer; typedef const empty_type & reference; typedef const empty_type & const_reference; - typedef const void value_type; typedef empty_type difference_type; typedef empty_type iterator_category; }; template<> struct random_it { - typedef volatile void * pointer; typedef const volatile void * const_pointer; typedef empty_type& reference; typedef const empty_type& const_reference; - typedef volatile void value_type; typedef empty_type difference_type; typedef empty_type iterator_category; }; template<> struct random_it { - typedef const volatile void * pointer; typedef const volatile void * const_pointer; typedef const empty_type & reference; typedef const empty_type & const_reference; - typedef const volatile void value_type; typedef empty_type difference_type; typedef empty_type iterator_category; }; @@ -96,7 +88,7 @@ template class smart_ptr { typedef random_it random_it_t; - typedef smart_ptr self_t; + typedef smart_ptr self_t; typedef typename random_it_t::const_pointer const_pointer_t; typedef typename random_it_t::const_reference const_reference_t; @@ -104,11 +96,11 @@ class smart_ptr typedef void (self_t::*unspecified_bool_type)() const; public: - typedef typename random_it_t::pointer pointer; - typedef typename random_it_t::reference reference; - typedef typename random_it_t::value_type value_type; - typedef typename random_it_t::difference_type difference_type; - typedef typename random_it_t::iterator_category iterator_category; + typedef PointedType * pointer; + typedef typename random_it_t::reference reference; + typedef PointedType value_type; + typedef typename random_it_t::difference_type difference_type; + typedef typename random_it_t::iterator_category iterator_category; PointedType *m_ptr; @@ -163,7 +155,7 @@ class smart_ptr {} /*!Obtains raw pointer from offset. Never throws.*/ - pointer get()const + pointer get() const { return m_ptr; } /*!Pointer-like -> operator. It can return 0 pointer. Never throws.*/ @@ -314,7 +306,7 @@ inline void swap (smart_ptr &pt, /*!get_pointer() enables boost::mem_fn to recognize smart_ptr. Never throws.*/ template -inline T * get_pointer(smart_ptr const & p) +inline T* get_pointer(const smart_ptr & p) { return p.get(); } /*!Simulation of static_cast between pointers. Never throws.*/ diff --git a/test/test_container.hpp b/test/test_container.hpp index 8f27704..f905ea8 100644 --- a/test/test_container.hpp +++ b/test/test_container.hpp @@ -1,7 +1,7 @@ ////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2006 Matias Capeletto -// Copyright (c) 2007 Ion Gaztaņaga +// Copyright (c) 2007 Ion Gaztanaga // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at diff --git a/test/test_macros.hpp b/test/test_macros.hpp new file mode 100644 index 0000000..d612b9f --- /dev/null +++ b/test/test_macros.hpp @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-2007 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP +#define BOOST_INTRUSIVE_TEST_TEST_MACROS_HPP + +#define TEST_INTRUSIVE_SEQUENCE( INTVALUES, ITERATOR )\ +{ \ + const int init_values_size = sizeof(INTVALUES)/sizeof(INTVALUES[0]); \ + std::vector expected; \ + expected.assign(&INTVALUES[0], &INTVALUES[0] + init_values_size); \ + BOOST_TEST (std::equal(expected.begin(), expected.end(), ITERATOR) ); \ +} + +#define TEST_INTRUSIVE_SEQUENCE_EXPECTED( EXPECTEDVECTOR, ITERATOR )\ +{ \ + BOOST_TEST (std::equal(EXPECTEDVECTOR.begin(), EXPECTEDVECTOR.end(), ITERATOR) ); \ +} + +#endif diff --git a/test/unordered_multiset_test.cpp b/test/unordered_multiset_test.cpp index a7cc383..4b6e94b 100644 --- a/test/unordered_multiset_test.cpp +++ b/test/unordered_multiset_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztaņaga 2006-2007. +// (C) Copyright Ion Gaztanaga 2006-2007. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -16,11 +16,10 @@ #include "itestvalue.hpp" #include "smart_ptr.hpp" #include "common_functors.hpp" - #include - -// Boost.Test -#include "boost/test/included/test_exec_monitor.hpp" +#include +#include +#include "test_macros.hpp" using namespace boost::intrusive; @@ -85,8 +84,6 @@ template void test_unordered_multiset::test_sort(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef boost::intrusive::unordered_multiset @@ -96,12 +93,10 @@ void test_unordered_multiset::test_sort(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("122345")); - + { int init_values [] = { 1, 2, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } testset1.clear(); - BOOST_CHECK (testset1.empty()); + BOOST_TEST (testset1.empty()); } //test: insert, const_iterator, const_reverse_iterator, erase, iterator_to: @@ -109,8 +104,6 @@ template void test_unordered_multiset::test_insert(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef boost::intrusive::unordered_multiset @@ -124,49 +117,44 @@ void test_unordered_multiset::test_insert(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("145")); + { int init_values [] = { 1, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); } - BOOST_DEDUCED_TYPENAME unordered_multiset_type::iterator i = testset.begin(); - BOOST_CHECK (i->value_ == 1); + typename unordered_multiset_type::iterator i = testset.begin(); + BOOST_TEST (i->value_ == 1); i = testset.insert (values[0]); - BOOST_CHECK (&*i == &values[0]); + BOOST_TEST (&*i == &values[0]); i = testset.iterator_to (values[2]); - BOOST_CHECK (&*i == &values[2]); + BOOST_TEST (&*i == &values[2]); testset.erase(i); - //test post-increment: - for (BOOST_DEDUCED_TYPENAME unordered_multiset_type::const_iterator i = const_testset.begin(), - e = const_testset.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("135")); + { int init_values [] = { 1, 3, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); } testset.clear(); testset.insert(&values[0], &values[0] + values.size()); - test_seq.clear(); - for (BOOST_DEDUCED_TYPENAME unordered_multiset_type::const_iterator i = const_testset.begin(), - e = const_testset.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("122345")); - BOOST_CHECK (testset.erase(1) == 1); - BOOST_CHECK (testset.erase(2) == 2); - BOOST_CHECK (testset.erase(3) == 1); - BOOST_CHECK (testset.erase(4) == 1); - BOOST_CHECK (testset.erase(5) == 1); - BOOST_CHECK (testset.empty() == true); + + { int init_values [] = { 1, 2, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); } + + BOOST_TEST (testset.erase(1) == 1); + BOOST_TEST (testset.erase(2) == 2); + BOOST_TEST (testset.erase(3) == 1); + BOOST_TEST (testset.erase(4) == 1); + BOOST_TEST (testset.erase(5) == 1); + BOOST_TEST (testset.empty() == true); //Now with a single bucket typename unordered_multiset_type::bucket_type single_bucket[1]; unordered_multiset_type testset2(single_bucket, 1); testset2.insert(&values[0], &values[0] + values.size()); - BOOST_CHECK (testset2.erase(5) == 1); - BOOST_CHECK (testset2.erase(2) == 2); - BOOST_CHECK (testset2.erase(1) == 1); - BOOST_CHECK (testset2.erase(4) == 1); - BOOST_CHECK (testset2.erase(3) == 1); - BOOST_CHECK (testset2.empty() == true); + BOOST_TEST (testset2.erase(5) == 1); + BOOST_TEST (testset2.erase(2) == 2); + BOOST_TEST (testset2.erase(1) == 1); + BOOST_TEST (testset2.erase(4) == 1); + BOOST_TEST (testset2.erase(3) == 1); + BOOST_TEST (testset2.empty() == true); } //test: insert (seq-version), swap, erase (seq-version), size: @@ -174,7 +162,6 @@ template void test_unordered_multiset::test_swap(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::unordered_multiset @@ -189,20 +176,17 @@ void test_unordered_multiset::test_swap(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("1245")); - //test post-increment: - for (BOOST_DEDUCED_TYPENAME unordered_multiset_type::iterator i = testset2.begin(), - e = testset2.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("23")); + + { int init_values [] = { 1, 2, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } + + { int init_values [] = { 2, 3 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); } testset1.erase (testset1.iterator_to(values[5]), testset1.end()); - BOOST_CHECK (testset1.size() == 1); - // BOOST_CHECK (&testset1.front() == &values[3]); - BOOST_CHECK (&*testset1.begin() == &values[3]); + BOOST_TEST (testset1.size() == 1); + // BOOST_TEST (&testset1.front() == &values[3]); + BOOST_TEST (&*testset1.begin() == &values[3]); } //test: rehash: @@ -210,8 +194,6 @@ template void test_unordered_multiset::test_rehash(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef boost::intrusive::unordered_multiset @@ -221,39 +203,33 @@ void test_unordered_multiset::test_rehash(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("122345")); + BOOST_TEST (testset1.size() == 6); + { int init_values [] = { 1, 2, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } typename unordered_multiset_type::bucket_type buckets2 [2]; testset1.rehash(buckets2, 2); - BOOST_CHECK (testset1.size() == 6); - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("422531")); - + BOOST_TEST (testset1.size() == 6); + { int init_values [] = { 4, 2, 2, 5, 3, 1 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } typename unordered_multiset_type::bucket_type buckets3 [BucketSize*2]; testset1.rehash(buckets3, BucketSize*2); - BOOST_CHECK (testset1.size() == 6); - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("122345")); + BOOST_TEST (testset1.size() == 6); + { int init_values [] = { 1, 2, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } //Now rehash reducing the buckets testset1.rehash(buckets3, 2); - BOOST_CHECK (testset1.size() == 6); - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("422531")); + BOOST_TEST (testset1.size() == 6); + { int init_values [] = { 4, 2, 2, 5, 3, 1 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } //Now rehash increasing the buckets testset1.rehash(buckets3, BucketSize*2); - BOOST_CHECK (testset1.size() == 6); - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("122345")); + BOOST_TEST (testset1.size() == 6); + { int init_values [] = { 1, 2, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } } //test: find, equal_range (lower_bound, upper_bound): @@ -261,7 +237,6 @@ template void test_unordered_multiset::test_find(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::unordered_multiset @@ -271,21 +246,21 @@ void test_unordered_multiset::test_find(std::vectorvalue_ == 2); - BOOST_CHECK ((++i)->value_ == 2); + BOOST_TEST (i->value_ == 2); + BOOST_TEST ((++i)->value_ == 2); std::pair range = testset.equal_range (cmp_val); - BOOST_CHECK (range.first->value_ == 2); - BOOST_CHECK (range.second->value_ == 3); - BOOST_CHECK (std::distance (range.first, range.second) == 2); + BOOST_TEST (range.first->value_ == 2); + BOOST_TEST (range.second->value_ == 3); + BOOST_TEST (std::distance (range.first, range.second) == 2); cmp_val.value_ = 7; - BOOST_CHECK (testset.find (cmp_val) == testset.end()); + BOOST_TEST (testset.find (cmp_val) == testset.end()); } @@ -312,9 +287,9 @@ void test_unordered_multiset src(testset1.begin(), testset1.end()); std::multiset dst(testset2.begin(), testset2.end()); - BOOST_CHECK (src == dst); + BOOST_TEST (src == dst); testset2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testset2.empty()); + BOOST_TEST (testset2.empty()); } { //Test with bigger source bucket arrays @@ -329,9 +304,9 @@ void test_unordered_multiset src(testset1.begin(), testset1.end()); std::multiset dst(testset2.begin(), testset2.end()); - BOOST_CHECK (src == dst); + BOOST_TEST (src == dst); testset2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testset2.empty()); + BOOST_TEST (testset2.empty()); } { //Test with smaller source bucket arrays @@ -346,9 +321,9 @@ void test_unordered_multiset src(testset1.begin(), testset1.end()); std::multiset dst(testset2.begin(), testset2.end()); - BOOST_CHECK (src == dst); + BOOST_TEST (src == dst); testset2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testset2.empty()); + BOOST_TEST (testset2.empty()); } } @@ -364,10 +339,10 @@ class test_main_template for (int i = 0; i < 6; ++i) data[i].value_ = random_init[i]; - test_unordered_multiset >::test_all(data); - test_unordered_multiset >::test_all(data); return 0; @@ -386,21 +361,21 @@ class test_main_template for (int i = 0; i < 6; ++i) data[i].value_ = random_init[i]; - test_unordered_multiset >::test_all(data); - test_unordered_multiset >::test_all(data); - test_unordered_multiset >::test_all(data); - test_unordered_multiset >::test_all(data); return 0; } }; - +/* //Explicit instantiations of non-counted classes template class boost::intrusive::unordered_multiset < unordered_set_base_raw_t @@ -452,12 +427,12 @@ template class boost::intrusive::unordered_multiset < unordered_set_member_smart_t , boost::hash , std::equal_to, true>; - -int test_main( int, char* [] ) +*/ +int main( int, char* [] ) { test_main_template()(); test_main_template, false>()(); test_main_template()(); test_main_template, true>()(); - return 0; + return boost::report_errors(); } diff --git a/test/unordered_set_test.cpp b/test/unordered_set_test.cpp index 4469f61..c59f16d 100644 --- a/test/unordered_set_test.cpp +++ b/test/unordered_set_test.cpp @@ -1,7 +1,7 @@ ///////////////////////////////////////////////////////////////////////////// // // (C) Copyright Olaf Krzikalla 2004-2006. -// (C) Copyright Ion Gaztaņaga 2006-2007. +// (C) Copyright Ion Gaztanaga 2006-2007. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -18,9 +18,8 @@ #include "common_functors.hpp" #include #include - -// Boost.Test -#include "boost/test/included/test_exec_monitor.hpp" +#include +#include "test_macros.hpp" using namespace boost::intrusive; @@ -75,7 +74,6 @@ void test_unordered_set::test_impl() testset.erase (testset.iterator_to (values[0])); testset.erase (testset.iterator_to (values[1])); testset.insert (values[1]); - testset.erase (testset.iterator_to (values[2])); testset.erase (testset.iterator_to (values[3])); } @@ -84,9 +82,7 @@ void test_unordered_set::test_impl() template void test_unordered_set::test_sort(std::vector& values) { - typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::unordered_set @@ -96,14 +92,12 @@ void test_unordered_set::test_sort(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("12345")); - + BOOST_TEST (5 == std::distance(testset1.begin(), testset1.end())); + { int init_values [] = { 1, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } + testset1.clear(); - BOOST_CHECK (testset1.empty()); + BOOST_TEST (testset1.empty()); } //test: insert, const_iterator, const_reverse_iterator, erase, iterator_to: @@ -111,7 +105,6 @@ template void test_unordered_set::test_insert(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; typedef boost::intrusive::unordered_set @@ -123,25 +116,22 @@ void test_unordered_set::test_insert(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("145")); + { int init_values [] = { 1, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); } - BOOST_DEDUCED_TYPENAME unordered_set_type::iterator i = testset.begin(); - BOOST_CHECK (i->value_ == 1); + typename unordered_set_type::iterator i = testset.begin(); + BOOST_TEST (i->value_ == 1); i = testset.insert(values[0]).first; - BOOST_CHECK (&*i == &values[0]); + BOOST_TEST (&*i == &values[0]); i = testset.iterator_to (values[2]); - BOOST_CHECK (&*i == &values[2]); + BOOST_TEST (&*i == &values[2]); testset.erase (i); - //test post-increment: - for (BOOST_DEDUCED_TYPENAME unordered_set_type::const_iterator i = const_testset.begin(), - e = const_testset.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("135")); + + { int init_values [] = { 1, 3, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, const_testset.begin() ); } } //test: insert (seq-version), swap, erase (seq-version), size: @@ -149,8 +139,6 @@ template void test_unordered_set::test_swap(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef boost::intrusive::unordered_set @@ -166,20 +154,16 @@ void test_unordered_set::test_swap(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("1245")); - //test post-increment: - for (BOOST_DEDUCED_TYPENAME unordered_set_type::iterator i = testset2.begin(), - e = testset2.end(); i != e; i++) - test_seq << *i; - BOOST_CHECK (test_seq.is_equal ("23")); + + { int init_values [] = { 1, 2, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } + { int init_values [] = { 2, 3 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); } testset1.erase (testset1.iterator_to(values[5]), testset1.end()); - BOOST_CHECK (testset1.size() == 1); - // BOOST_CHECK (&testset1.front() == &values[3]); - BOOST_CHECK (&*testset1.begin() == &values[3]); + BOOST_TEST (testset1.size() == 1); + // BOOST_TEST (&testset1.front() == &values[3]); + BOOST_TEST (&*testset1.begin() == &values[3]); } //test: rehash: @@ -187,8 +171,6 @@ template void test_unordered_set::test_rehash(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef boost::intrusive::unordered_set @@ -198,38 +180,33 @@ void test_unordered_set::test_rehash(std::vector (test_seq)); - BOOST_CHECK (test_seq.is_equal ("12345")); + BOOST_TEST (testset1.size() == 5); + { int init_values [] = { 1, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } typename unordered_set_type::bucket_type buckets2 [2]; testset1.rehash(buckets2, 2); - BOOST_CHECK (testset1.size() == 5); - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("42531")); + BOOST_TEST (testset1.size() == 5); + { int init_values [] = { 4, 2, 5, 3, 1 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } typename unordered_set_type::bucket_type buckets3 [BucketSize*2]; testset1.rehash(buckets3, BucketSize*2); - BOOST_CHECK (testset1.size() == 5); - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("12345")); + BOOST_TEST (testset1.size() == 5); + { int init_values [] = { 1, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } //Now rehash reducing the buckets testset1.rehash(buckets3, 2); - BOOST_CHECK (testset1.size() == 5); - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("42531")); + BOOST_TEST (testset1.size() == 5); + { int init_values [] = { 4, 2, 5, 3, 1 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } //Now rehash increasing the buckets testset1.rehash(buckets3, BucketSize*2); - BOOST_CHECK (testset1.size() == 5); - std::copy (testset1.begin(), testset1.end(), - std::ostream_iterator (test_seq)); - BOOST_CHECK (test_seq.is_equal ("12345")); + BOOST_TEST (testset1.size() == 5); + { int init_values [] = { 1, 2, 3, 4, 5 }; + TEST_INTRUSIVE_SEQUENCE( init_values, testset1.begin() ); } } @@ -238,8 +215,6 @@ template void test_unordered_set::test_find(std::vector& values) { typedef typename ValueTraits::value_type testvalue_t; - boost::test_tools::output_test_stream test_seq; - typedef boost::intrusive::unordered_set @@ -248,21 +223,21 @@ void test_unordered_set::test_find(std::vector unordered_set_type; typename unordered_set_type::bucket_type buckets [BucketSize]; unordered_set_type testset (buckets, BucketSize, values.begin(), values.end()); - typedef BOOST_DEDUCED_TYPENAME unordered_set_type::iterator iterator; + typedef typename unordered_set_type::iterator iterator; testvalue_t cmp_val; cmp_val.value_ = 2; iterator i = testset.find (cmp_val); - BOOST_CHECK (i->value_ == 2); - BOOST_CHECK ((++i)->value_ != 2); + BOOST_TEST (i->value_ == 2); + BOOST_TEST ((++i)->value_ != 2); std::pair range = testset.equal_range (cmp_val); - BOOST_CHECK (range.first->value_ == 2); - BOOST_CHECK (range.second->value_ == 3); - BOOST_CHECK (std::distance (range.first, range.second) == 1); + BOOST_TEST (range.first->value_ == 2); + BOOST_TEST (range.second->value_ == 3); + BOOST_TEST (std::distance (range.first, range.second) == 1); cmp_val.value_ = 7; - BOOST_CHECK (testset.find (cmp_val) == testset.end()); + BOOST_TEST (testset.find (cmp_val) == testset.end()); } template @@ -288,9 +263,9 @@ void test_unordered_set src(testset1.begin(), testset1.end()); std::set dst(testset2.begin(), testset2.end()); - BOOST_CHECK (src == dst ); + BOOST_TEST (src == dst ); testset2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testset2.empty()); + BOOST_TEST (testset2.empty()); } { //Test with bigger source bucket arrays @@ -305,9 +280,9 @@ void test_unordered_set src(testset1.begin(), testset1.end()); std::set dst(testset2.begin(), testset2.end()); - BOOST_CHECK (src == dst ); + BOOST_TEST (src == dst ); testset2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testset2.empty()); + BOOST_TEST (testset2.empty()); } { //Test with smaller source bucket arrays @@ -322,9 +297,9 @@ void test_unordered_set src(testset1.begin(), testset1.end()); std::set dst(testset2.begin(), testset2.end()); - BOOST_CHECK (src == dst ); + BOOST_TEST (src == dst ); testset2.clear_and_destroy(test::delete_destroyer()); - BOOST_CHECK (testset2.empty()); + BOOST_TEST (testset2.empty()); } } @@ -340,10 +315,10 @@ class test_main_template for (int i = 0; i < 6; ++i) data[i].value_ = random_init[i]; - test_unordered_set >::test_all(data); - test_unordered_set >::test_all(data); return 0; @@ -362,21 +337,21 @@ class test_main_template for (int i = 0; i < 6; ++i) data[i].value_ = random_init[i]; - test_unordered_set >::test_all(data); - test_unordered_set >::test_all(data); - test_unordered_set >::test_all(data); - test_unordered_set >::test_all(data); return 0; } }; - +/* template class boost::intrusive::unordered_set < unordered_set_base_raw_t , boost::hash @@ -427,12 +402,12 @@ template class boost::intrusive::unordered_set < unordered_set_member_smart_t , boost::hash , std::equal_to, true>; - -int test_main( int, char* [] ) +*/ +int main( int, char* [] ) { test_main_template()(); test_main_template, false>()(); test_main_template()(); test_main_template, true>()(); - return 0; + return boost::report_errors(); }