Boost logo

Boost-Commit :

From: nesotto_at_[hidden]
Date: 2008-02-17 11:50:03


Author: nesotto
Date: 2008-02-17 11:50:02 EST (Sun, 17 Feb 2008)
New Revision: 43293
URL: http://svn.boost.org/trac/boost/changeset/43293

Log:
support for comparison operators
Text files modified:
   trunk/libs/assign/test/list_of.cpp | 40 ++++++++++++++++++++++++++++++++++++++--
   1 files changed, 38 insertions(+), 2 deletions(-)

Modified: trunk/libs/assign/test/list_of.cpp
==============================================================================
--- trunk/libs/assign/test/list_of.cpp (original)
+++ trunk/libs/assign/test/list_of.cpp 2008-02-17 11:50:02 EST (Sun, 17 Feb 2008)
@@ -224,7 +224,44 @@
 */
 }
 
+//
+// @remark: ADL is required here, but it is a bit wierd to
+// open up namespace std. Perhaps Boost.Test needs a
+// better configuration option.
+//
+namespace std
+{
+ template< class T, class Elem, class Traits >
+ inline std::basic_ostream<Elem,Traits>&
+ operator<<( std::basic_ostream<Elem, Traits>& Os,
+ const std::vector<T>& r )
+ {
+ return Os << ::boost::make_iterator_range( r.begin(), r.end() );
+ }
+}
 
+template <class Seq>
+inline std::vector<int> as_seq( const Seq& s )
+{
+ std::vector<int> c;
+ return s.to_container( c );
+}
+
+void test_comparison_operations()
+{
+ BOOST_CHECK_EQUAL( ba::list_of(0)(1)(2), as_seq(ba::list_of(0)(1)(2)) );
+ BOOST_CHECK_NE( ba::list_of(0)(1)(2), as_seq(ba::list_of(-1)(1)(2)) );
+ BOOST_CHECK_LT( ba::list_of(0)(1)(2), as_seq(ba::list_of(0)(1)(3)) );
+ BOOST_CHECK_LE( ba::list_of(0)(1)(2), as_seq(ba::list_of(0)(1)(2)) );
+ BOOST_CHECK_GT( ba::list_of(0)(1)(3), as_seq(ba::list_of(0)(1)(2)) );
+ BOOST_CHECK_GE( ba::list_of(0)(1)(2), as_seq(ba::list_of(0)(1)(2)) );
+ BOOST_CHECK_EQUAL( as_seq(ba::list_of(0)(1)(2)), ba::list_of(0)(1)(2) );
+ BOOST_CHECK_NE( as_seq(ba::list_of(0)(1)(2)), ba::list_of(-1)(1)(2) );
+ BOOST_CHECK_LT( as_seq(ba::list_of(0)(1)(2)), ba::list_of(0)(1)(3) );
+ BOOST_CHECK_LE( as_seq(ba::list_of(0)(1)(2)), ba::list_of(0)(1)(2) );
+ BOOST_CHECK_GT( as_seq(ba::list_of(0)(1)(3)), ba::list_of(0)(1)(2) );
+ BOOST_CHECK_GE( as_seq(ba::list_of(0)(1)(2)), ba::list_of(0)(1)(2) );
+}
 
 void check_list_of()
 {
@@ -242,9 +279,8 @@
     
     std::stack<std::string> s = ba::list_of( "Foo" )( "Bar" )( "FooBar" ).to_adapter( s );
     test_list_of();
-
     test_vector_matrix();
-
+ test_comparison_operations();
 }
 
 


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