Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59582 - trunk/libs/multi_index/test
From: joaquin_at_[hidden]
Date: 2010-02-08 10:56:07


Author: joaquin
Date: 2010-02-08 10:56:06 EST (Mon, 08 Feb 2010)
New Revision: 59582
URL: http://svn.boost.org/trac/boost/changeset/59582

Log:
eliminated dubious use of preprocessor
Text files modified:
   trunk/libs/multi_index/test/test_list_ops.cpp | 54 +++++++++++++++++++--------------------
   trunk/libs/multi_index/test/test_range.cpp | 28 +++++++++-----------
   trunk/libs/multi_index/test/test_rearrange.cpp | 22 +++++++--------
   3 files changed, 49 insertions(+), 55 deletions(-)

Modified: trunk/libs/multi_index/test/test_list_ops.cpp
==============================================================================
--- trunk/libs/multi_index/test/test_list_ops.cpp (original)
+++ trunk/libs/multi_index/test/test_list_ops.cpp 2010-02-08 10:56:06 EST (Mon, 08 Feb 2010)
@@ -1,6 +1,6 @@
 /* Boost.MultiIndex test for standard list operations.
  *
- * Copyright 2003-2009 Joaquin M Lopez Munoz.
+ * Copyright 2003-2010 Joaquin M Lopez Munoz.
  * 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)
@@ -19,17 +19,15 @@
 #include <boost/multi_index/ordered_index.hpp>
 #include <boost/multi_index/sequenced_index.hpp>
 #include <boost/multi_index/random_access_index.hpp>
+#include <boost/preprocessor/seq/enum.hpp>
 #include <boost/test/test_tools.hpp>
 
 using namespace boost::multi_index;
 
-#undef _
-#define _ ,
-
 #undef CHECK_EQUAL
-#define CHECK_EQUAL(p,check_range) \
+#define CHECK_EQUAL(p,check_seq) \
 {\
- int v[]=check_range;\
+ int v[]={BOOST_PP_SEQ_ENUM(check_seq)};\
   std::size_t size_v=sizeof(v)/sizeof(int);\
   BOOST_CHECK(std::size_t(std::distance((p).begin(),(p).end()))==size_v);\
   BOOST_CHECK(std::equal((p).begin(),(p).end(),&v[0]));\
@@ -92,37 +90,37 @@
   si.insert(project<1>(ss,ss.find(2)),8); /* 34082561 */
   si2=si;
 
- CHECK_EQUAL(si,{3 _ 4 _ 0 _ 8 _ 2 _ 5 _ 6 _ 1});
+ CHECK_EQUAL(si,(3)(4)(0)(8)(2)(5)(6)(1));
 
   si.remove(8);
- CHECK_EQUAL(si,{3 _ 4 _ 0 _ 2 _ 5 _ 6 _ 1});
+ CHECK_EQUAL(si,(3)(4)(0)(2)(5)(6)(1));
 
   si.remove_if(is_even());
 
- CHECK_EQUAL(si,{3 _ 5 _ 1});
+ CHECK_EQUAL(si,(3)(5)(1));
 
   si.splice(si.end(),si2);
- CHECK_EQUAL(si,{3 _ 5 _ 1 _ 4 _ 0 _ 8 _ 2 _ 6});
- CHECK_EQUAL(si2,{3 _ 5 _ 1});
+ CHECK_EQUAL(si,(3)(5)(1)(4)(0)(8)(2)(6));
+ CHECK_EQUAL(si2,(3)(5)(1));
 
   si.splice(project<1>(ss,ss.find(4)),si,project<1>(ss,ss.find(8)));
- CHECK_EQUAL(si,{3 _ 5 _ 1 _ 8 _ 4 _ 0 _ 2 _ 6});
+ CHECK_EQUAL(si,(3)(5)(1)(8)(4)(0)(2)(6));
   si2.clear();
   si2.splice(si2.begin(),si,si.begin());
 
   si.splice(si.end(),si2,si2.begin());
- CHECK_EQUAL(si,{5 _ 1 _ 8 _ 4 _ 0 _ 2 _ 6 _ 3});
+ CHECK_EQUAL(si,(5)(1)(8)(4)(0)(2)(6)(3));
   BOOST_CHECK(si2.empty());
 
   si2.splice(si2.end(),si,project<1>(ss,ss.find(0)),project<1>(ss,ss.find(6)));
- CHECK_EQUAL(si,{5 _ 1 _ 8 _ 4 _ 6 _ 3});
- CHECK_EQUAL(si2,{0 _ 2});
+ CHECK_EQUAL(si,(5)(1)(8)(4)(6)(3));
+ CHECK_EQUAL(si2,(0)(2));
 
   si.splice(si.begin(),si,si.begin(),si.begin());
- CHECK_EQUAL(si,{5 _ 1 _ 8 _ 4 _ 6 _ 3});
+ CHECK_EQUAL(si,(5)(1)(8)(4)(6)(3));
 
   si.splice(project<1>(ss,ss.find(8)),si,project<1>(ss,ss.find(4)),si.end());
- CHECK_EQUAL(si,{5 _ 1 _ 4 _ 6 _ 3 _ 8});
+ CHECK_EQUAL(si,(5)(1)(4)(6)(3)(8));
 
   si.sort();
   si2.sort();
@@ -143,7 +141,7 @@
   }
 
   si2.splice(si2.end(),si,project<1>(ss,ss.find(6)),project<1>(ss,ss.find(3)));
- CHECK_EQUAL(si2,{6 _ 5 _ 4});
+ CHECK_EQUAL(si2,(6)(5)(4));
 
   si.merge(si2,std::greater<int>());
   BOOST_CHECK(is_sorted(si,std::greater<int>()));
@@ -176,8 +174,8 @@
   ss.unique();
   CHECK_EQUAL(
     ss,
- {9 _ 8 _ 7 _ 6 _ 5 _ 4 _ 3 _ 2 _ 1 _ 0 _
- 1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9});
+ (9)(8)(7)(6)(5)(4)(3)(2)(1)(0)
+ (1)(2)(3)(4)(5)(6)(7)(8)(9));
 
   iterator it=ss.begin();
   for(int j=0;j<9;++j,++it){} /* it points to o */
@@ -188,14 +186,14 @@
   ss.merge(ss2);
   CHECK_EQUAL(
     ss,
- {0 _ 1 _ 1 _ 2 _ 2 _ 3 _ 3 _ 4 _ 4 _ 5 _ 5 _
- 6 _ 6 _ 7 _ 7 _ 8 _ 8 _ 9 _ 9});
+ (0)(1)(1)(2)(2)(3)(3)(4)(4)(5)(5)
+ (6)(6)(7)(7)(8)(8)(9)(9));
 
   ss.unique(same_integral_div<3>());
- CHECK_EQUAL(ss,{0 _ 3 _ 6 _ 9});
+ CHECK_EQUAL(ss,(0)(3)(6)(9));
 
   ss.unique(same_integral_div<1>());
- CHECK_EQUAL(ss,{0 _ 3 _ 6 _ 9});
+ CHECK_EQUAL(ss,(0)(3)(6)(9));
 
   /* testcases for bugs reported at
    * http://lists.boost.org/boost-users/2006/09/22604.php
@@ -205,7 +203,7 @@
     ss.push_back(0);
     ss2.push_back(0);
     ss.splice(ss.end(),ss2,ss2.begin());
- CHECK_EQUAL(ss,{0 _ 0});
+ CHECK_EQUAL(ss,(0)(0));
     BOOST_CHECK(ss2.empty());
 
     ss.clear();
@@ -213,7 +211,7 @@
     ss.push_back(0);
     ss2.push_back(0);
     ss.splice(ss.end(),ss2,ss2.begin(),ss2.end());
- CHECK_EQUAL(ss,{0 _ 0});
+ CHECK_EQUAL(ss,(0)(0));
     BOOST_CHECK(ss2.empty());
 
     ss.clear();
@@ -221,7 +219,7 @@
     ss.push_back(0);
     ss2.push_back(0);
     ss.merge(ss2);
- CHECK_EQUAL(ss,{0 _ 0});
+ CHECK_EQUAL(ss,(0)(0));
     BOOST_CHECK(ss2.empty());
 
     typedef typename Sequence::value_type value_type;
@@ -230,7 +228,7 @@
     ss.push_back(0);
     ss2.push_back(0);
     ss.merge(ss2,std::less<value_type>());
- CHECK_EQUAL(ss,{0 _ 0});
+ CHECK_EQUAL(ss,(0)(0));
     BOOST_CHECK(ss2.empty());
   }
 }

Modified: trunk/libs/multi_index/test/test_range.cpp
==============================================================================
--- trunk/libs/multi_index/test/test_range.cpp (original)
+++ trunk/libs/multi_index/test/test_range.cpp 2010-02-08 10:56:06 EST (Mon, 08 Feb 2010)
@@ -1,6 +1,6 @@
 /* Boost.MultiIndex test for range().
  *
- * Copyright 2003-2008 Joaquin M Lopez Munoz.
+ * Copyright 2003-2010 Joaquin M Lopez Munoz.
  * 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)
@@ -17,6 +17,7 @@
 #include <boost/multi_index_container.hpp>
 #include <boost/multi_index/identity.hpp>
 #include <boost/multi_index/ordered_index.hpp>
+#include <boost/preprocessor/seq/enum.hpp>
 #include <boost/test/test_tools.hpp>
 
 using namespace boost::multi_index;
@@ -24,13 +25,10 @@
 typedef multi_index_container<int> int_set;
 typedef int_set::iterator int_set_iterator;
 
-#undef _
-#define _ ,
-
 #undef CHECK_RANGE
-#define CHECK_RANGE(p,check_range) \
+#define CHECK_RANGE(p,check_seq) \
 {\
- int v[]=check_range;\
+ int v[]={BOOST_PP_SEQ_ENUM(check_seq)};\
   std::size_t size_v=sizeof(v)/sizeof(int);\
   BOOST_CHECK(std::size_t(std::distance((p).first,(p).second))==size_v);\
   BOOST_CHECK(std::equal((p).first,(p).second,&v[0]));\
@@ -48,17 +46,17 @@
   std::pair<int_set::iterator,int_set::iterator> p;
 
   p=is.range(unbounded,unbounded);
- CHECK_RANGE(p,{1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 _ 10});
+ CHECK_RANGE(p,(1)(2)(3)(4)(5)(6)(7)(8)(9)(10));
 
   p=is.range(
     std::bind1st(std::less<int>(),5), /* 5 < x */
     unbounded);
- CHECK_RANGE(p,{6 _ 7 _ 8 _ 9 _ 10});
+ CHECK_RANGE(p,(6)(7)(8)(9)(10));
 
   p=is.range(
     std::bind1st(std::less_equal<int>(),8), /* 8 <= x */
     unbounded);
- CHECK_RANGE(p,{8 _ 9 _ 10});
+ CHECK_RANGE(p,(8)(9)(10));
 
   p=is.range(
     std::bind1st(std::less_equal<int>(),11), /* 11 <= x */
@@ -68,12 +66,12 @@
   p=is.range(
     unbounded,
     std::bind2nd(std::less<int>(),8)); /* x < 8 */
- CHECK_RANGE(p,{1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7});
+ CHECK_RANGE(p,(1)(2)(3)(4)(5)(6)(7));
 
   p=is.range(
     unbounded,
     std::bind2nd(std::less_equal<int>(),4)); /* x <= 4 */
- CHECK_RANGE(p,{1 _ 2 _ 3 _ 4});
+ CHECK_RANGE(p,(1)(2)(3)(4));
 
   p=is.range(
     unbounded,
@@ -83,22 +81,22 @@
   p=is.range(
     std::bind1st(std::less<int>(),6), /* 6 < x */
     std::bind2nd(std::less_equal<int>(),9)); /* x <= 9 */
- CHECK_RANGE(p,{7 _ 8 _ 9});
+ CHECK_RANGE(p,(7)(8)(9));
 
   p=is.range(
     std::bind1st(std::less_equal<int>(),4), /* 4 <= x */
     std::bind2nd(std::less<int>(),5)); /* x < 5 */
- CHECK_RANGE(p,{4});
+ CHECK_RANGE(p,(4));
 
   p=is.range(
     std::bind1st(std::less_equal<int>(),10), /* 10 <= x */
     std::bind2nd(std::less_equal<int>(),10)); /* x <= 10 */
- CHECK_RANGE(p,{10});
+ CHECK_RANGE(p,(10));
 
   p=is.range(
     std::bind1st(std::less<int>(),0), /* 0 < x */
     std::bind2nd(std::less<int>(),11)); /* x < 11 */
- CHECK_RANGE(p,{1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 _ 10});
+ CHECK_RANGE(p,(1)(2)(3)(4)(5)(6)(7)(8)(9)(10));
 
   p=is.range(
     std::bind1st(std::less<int>(),7), /* 7 < x */

Modified: trunk/libs/multi_index/test/test_rearrange.cpp
==============================================================================
--- trunk/libs/multi_index/test/test_rearrange.cpp (original)
+++ trunk/libs/multi_index/test/test_rearrange.cpp 2010-02-08 10:56:06 EST (Mon, 08 Feb 2010)
@@ -1,6 +1,6 @@
 /* Boost.MultiIndex test for rearrange operations.
  *
- * Copyright 2003-2008 Joaquin M Lopez Munoz.
+ * Copyright 2003-2010 Joaquin M Lopez Munoz.
  * 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)
@@ -18,19 +18,17 @@
 #include <boost/multi_index/sequenced_index.hpp>
 #include <boost/multi_index/random_access_index.hpp>
 #include <boost/next_prior.hpp>
+#include <boost/preprocessor/seq/enum.hpp>
 #include <boost/ref.hpp>
 #include <boost/test/test_tools.hpp>
 #include <vector>
 
 using namespace boost::multi_index;
 
-#undef _
-#define _ ,
-
 #undef CHECK_EQUAL
-#define CHECK_EQUAL(p,check_range) \
+#define CHECK_EQUAL(p,check_seq) \
 {\
- int v[]=check_range;\
+ int v[]={BOOST_PP_SEQ_ENUM(check_seq)};\
   std::size_t size_v=sizeof(v)/sizeof(int);\
   BOOST_CHECK(std::size_t(std::distance((p).begin(),(p).end()))==size_v);\
   BOOST_CHECK(std::equal((p).begin(),(p).end(),&v[0]));\
@@ -67,29 +65,29 @@
   it=sc.begin();
   std::advance(it,3);
   sc.relocate(sc.begin(),it);
- CHECK_EQUAL(sc,{3 _ 0 _ 1 _ 2 _ 4 _ 5});
+ CHECK_EQUAL(sc,(3)(0)(1)(2)(4)(5));
   BOOST_CHECK(it==sc.begin());
 
   sc.relocate(it,it);
- CHECK_EQUAL(sc,{3 _ 0 _ 1 _ 2 _ 4 _ 5});
+ CHECK_EQUAL(sc,(3)(0)(1)(2)(4)(5));
 
   std::advance(it,3);
   sc.relocate(sc.end(),it,sc.end());
- CHECK_EQUAL(sc,{3 _ 0 _ 1 _ 2 _ 4 _ 5});
+ CHECK_EQUAL(sc,(3)(0)(1)(2)(4)(5));
 
   sc.relocate(sc.begin(),it,it);
- CHECK_EQUAL(sc,{3 _ 0 _ 1 _ 2 _ 4 _ 5});
+ CHECK_EQUAL(sc,(3)(0)(1)(2)(4)(5));
 
   iterator it2;
 
   it2=sc.begin();
   ++it2;
   sc.relocate(it2,it,sc.end());
- CHECK_EQUAL(sc,{3 _ 2 _ 4 _ 5 _ 0 _ 1});
+ CHECK_EQUAL(sc,(3)(2)(4)(5)(0)(1));
   BOOST_CHECK(std::distance(it,it2)==3);
 
   sc.relocate(boost::prior(sc.end()),it,it2);
- CHECK_EQUAL(sc,{3 _ 0 _ 2 _ 4 _ 5 _ 1});
+ CHECK_EQUAL(sc,(3)(0)(2)(4)(5)(1));
 
   std::vector<boost::reference_wrapper<const value_type> > v;
   for(iterator it3=sc.begin();it3!=sc.end();++it3){


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