Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81245 - trunk/libs/test/test
From: gennadiy.rozental_at_[hidden]
Date: 2012-11-08 02:18:11


Author: rogeeff
Date: 2012-11-08 02:18:11 EST (Thu, 08 Nov 2012)
New Revision: 81245
URL: http://svn.boost.org/trac/boost/changeset/81245

Log:
test update
Text files modified:
   trunk/libs/test/test/test_assertion_construction.cpp | 194 ++++++++++++++++++++++++++++++---------
   1 files changed, 147 insertions(+), 47 deletions(-)

Modified: trunk/libs/test/test/test_assertion_construction.cpp
==============================================================================
--- trunk/libs/test/test/test_assertion_construction.cpp (original)
+++ trunk/libs/test/test/test_assertion_construction.cpp 2012-11-08 02:18:11 EST (Thu, 08 Nov 2012)
@@ -19,48 +19,54 @@
 
 //____________________________________________________________________________//
 
+#if BOOST_NO_CXX11_AUTO_DECLARATIONS
+#define EXPR_TYPE assertion::expression const&
+#else
+#define EXPR_TYPE auto const&
+#endif
+
 BOOST_AUTO_TEST_CASE( test_basic_value_expression_construction )
 {
     using namespace boost::test_tools;
     assertion::seed seed;
 
     {
- assertion::expression const& E = assertion::seed()->*1;
+ EXPR_TYPE E = assertion::seed()->*1;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( res );
         BOOST_CHECK( res.message().is_empty() );
     }
 
     {
- assertion::expression const& E = seed->*0;
+ EXPR_TYPE E = seed->*0;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)0 is false" );
     }
 
     {
- assertion::expression const& E = seed->*true;
+ EXPR_TYPE E = seed->*true;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( res );
         BOOST_CHECK( res.message().is_empty() );
     }
 
     {
- assertion::expression const& E = seed->*1.5;
+ EXPR_TYPE E = seed->*1.5;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( res );
     }
 
 #ifndef BOOST_NO_DECLTYPE
     {
- assertion::expression const& E = seed->* "abc";
+ EXPR_TYPE E = seed->* "abc";
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( res );
     }
 #endif
 
     {
- assertion::expression const& E = seed->* 1>2;
+ EXPR_TYPE E = seed->* 1>2;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "1<=2" );
@@ -76,28 +82,28 @@
     assertion::seed seed;
 
     {
- assertion::expression const& E = seed->* 1>2;
+ EXPR_TYPE E = seed->* 1>2;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "1<=2" );
     }
 
     {
- assertion::expression const& E = seed->* 100 < 50;
+ EXPR_TYPE E = seed->* 100 < 50;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "100>=50" );
     }
 
     {
- assertion::expression const& E = seed->* 5<=4;
+ EXPR_TYPE E = seed->* 5<=4;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "5>4" );
     }
 
     {
- assertion::expression const& E = seed->* 10>=20;
+ EXPR_TYPE E = seed->* 10>=20;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "10<20" );
@@ -105,7 +111,7 @@
 
     {
         int i = 10;
- assertion::expression const& E = seed->* i != 10;
+ EXPR_TYPE E = seed->* i != 10;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "10==10" );
@@ -113,7 +119,7 @@
 
     {
         int i = 5;
- assertion::expression const& E = seed->* i == 3;
+ EXPR_TYPE E = seed->* i == 3;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "5!=3" );
@@ -132,7 +138,7 @@
     {
         int i = 3;
         int j = 5;
- assertion::expression const& E = seed->* i+j !=8;
+ EXPR_TYPE E = seed->* i+j !=8;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "3+5==8" );
@@ -141,7 +147,7 @@
     {
         int i = 3;
         int j = 5;
- assertion::expression const& E = seed->* 2*i-j > 1;
+ EXPR_TYPE E = seed->* 2*i-j > 1;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "2*3-5<=1" );
@@ -149,7 +155,7 @@
 
     {
         int j = 5;
- assertion::expression const& E = seed->* 2<<j < 30;
+ EXPR_TYPE E = seed->* 2<<j < 30;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "2<<5>=30" );
@@ -158,7 +164,7 @@
     {
         int i = 2;
         int j = 5;
- assertion::expression const& E = seed->* i&j;
+ EXPR_TYPE E = seed->* i&j;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "2&5" );
@@ -167,16 +173,16 @@
     {
         int i = 3;
         int j = 5;
- assertion::expression const& E = seed->* i^j^6;
+ EXPR_TYPE E = seed->* i^j^6;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "3^5^6" );
     }
 
     // do not support
- // assertion::expression const& E = seed->*99/2 == 48 || 101/2 > 50;
- // assertion::expression const& E = seed->* a ? 100 < 50 : 25*2 == 50;
- // assertion::expression const& E = seed->* true,false;
+ // EXPR_TYPE E = seed->*99/2 == 48 || 101/2 > 50;
+ // EXPR_TYPE E = seed->* a ? 100 < 50 : 25*2 == 50;
+ // EXPR_TYPE E = seed->* true,false;
 }
 
 //____________________________________________________________________________//
@@ -188,7 +194,7 @@
 
     Testee() : m_value( false ) {}
     Testee( Testee const& ) : m_value(false) { s_copy_counter++; }
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
     Testee( Testee&& ) : m_value(false) {}
     Testee( Testee const&& ) : m_value(false) {}
 #endif
@@ -203,7 +209,7 @@
 
 int Testee::s_copy_counter = 0;
 
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
 Testee get_obj() { return std::move( Testee() ); }
 Testee const get_const_obj() { return std::move( Testee() ); }
 #else
@@ -211,6 +217,17 @@
 Testee const get_const_obj() { return Testee(); }
 #endif
 
+class NC : boost::noncopyable {
+public:
+ NC() {}
+
+ bool operator==(NC const&) { return false; }
+ friend std::ostream& operator<<(std::ostream& ostr, NC const&)
+ {
+ return ostr << "NC";
+ }
+};
+
 BOOST_AUTO_TEST_CASE( test_objects )
 {
     using namespace boost::test_tools;
@@ -220,11 +237,11 @@
         Testee obj;
         Testee::s_copy_counter = 0;
 
- assertion::expression const& E = seed->* obj;
+ EXPR_TYPE E = seed->* obj;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)Testee is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( Testee::s_copy_counter, 0 );
 #else
         BOOST_CHECK_EQUAL( Testee::s_copy_counter, 1 );
@@ -235,11 +252,11 @@
         Testee const obj;
         Testee::s_copy_counter = 0;
 
- assertion::expression const& E = seed->* obj;
+ EXPR_TYPE E = seed->* obj;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)Testee is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( Testee::s_copy_counter, 0 );
 #else
         BOOST_CHECK_EQUAL( Testee::s_copy_counter, 1 );
@@ -249,11 +266,11 @@
     {
         Testee::s_copy_counter = 0;
 
- assertion::expression const& E = seed->* get_obj();
+ EXPR_TYPE E = seed->* get_obj();
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)Testee is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( Testee::s_copy_counter, 0 );
 #else
         BOOST_CHECK_EQUAL( Testee::s_copy_counter, 1 );
@@ -263,16 +280,45 @@
     {
         Testee::s_copy_counter = 0;
 
- assertion::expression const& E = seed->* get_const_obj();
+ EXPR_TYPE E = seed->* get_const_obj();
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)Testee is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ BOOST_CHECK_EQUAL( Testee::s_copy_counter, 0 );
+#else
+ BOOST_CHECK_EQUAL( Testee::s_copy_counter, 1 );
+#endif
+ }
+
+ {
+ Testee::s_copy_counter = 0;
+
+ Testee t1;
+ Testee t2;
+
+ EXPR_TYPE E = seed->* t1 != t2;
+ predicate_result const& res = E.evaluate();
+ BOOST_CHECK( !res );
+ BOOST_CHECK_EQUAL( res.message(), "Testee==Testee" );
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( Testee::s_copy_counter, 0 );
 #else
         BOOST_CHECK_EQUAL( Testee::s_copy_counter, 1 );
 #endif
     }
+
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
+ {
+ NC nc1;
+ NC nc2;
+
+ EXPR_TYPE E = seed->* nc1 == nc2;
+ predicate_result const& res = E.evaluate();
+ BOOST_CHECK( !res );
+ BOOST_CHECK_EQUAL( res.message(), "NC!=NC" );
+ }
+#endif
 }
 
 //____________________________________________________________________________//
@@ -285,7 +331,7 @@
     {
         Testee* ptr = 0;
 
- assertion::expression const& E = seed->* ptr;
+ EXPR_TYPE E = seed->* ptr;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
     }
@@ -294,7 +340,7 @@
         Testee obj1;
         Testee obj2;
 
- assertion::expression const& E = seed->* &obj1 == &obj2;
+ EXPR_TYPE E = seed->* &obj1 == &obj2;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
     }
@@ -303,7 +349,7 @@
         Testee obj;
         Testee* ptr =&obj;
 
- assertion::expression const& E = seed->* *ptr;
+ EXPR_TYPE E = seed->* *ptr;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)Testee is false" );
@@ -315,7 +361,7 @@
         Testee* ptr =&obj;
         bool Testee::* mem_ptr =&Testee::m_value;
 
- assertion::expression const& E = seed->* ptr->*mem_ptr;
+ EXPR_TYPE E = seed->* ptr->*mem_ptr;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
     }
@@ -324,7 +370,7 @@
     // do not support
     // Testee obj;
     // bool Testee::* mem_ptr =&Testee::m_value;
- // assertion::expression const& E = seed->* obj.*mem_ptr;
+ // EXPR_TYPE E = seed->* obj.*mem_ptr;
 }
 
 //____________________________________________________________________________//
@@ -337,11 +383,11 @@
     {
         int j = 5;
 
- assertion::expression const& E = seed->* j = 0;
+ EXPR_TYPE E = seed->* j = 0;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)0 is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( j, 0 );
 #else
         BOOST_CHECK_EQUAL( j, 5 );
@@ -351,11 +397,11 @@
     {
         int j = 5;
 
- assertion::expression const& E = seed->* j -= 5;
+ EXPR_TYPE E = seed->* j -= 5;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)0 is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( j, 0 );
 #else
         BOOST_CHECK_EQUAL( j, 5 );
@@ -365,11 +411,11 @@
     {
         int j = 5;
 
- assertion::expression const& E = seed->* j *= 0;
+ EXPR_TYPE E = seed->* j *= 0;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)0 is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( j, 0 );
 #else
         BOOST_CHECK_EQUAL( j, 5 );
@@ -379,11 +425,11 @@
     {
         int j = 5;
 
- assertion::expression const& E = seed->* j /= 10;
+ EXPR_TYPE E = seed->* j /= 10;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)0 is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( j, 0 );
 #else
         BOOST_CHECK_EQUAL( j, 5 );
@@ -393,11 +439,11 @@
     {
         int j = 4;
 
- assertion::expression const& E = seed->* j %= 2;
+ EXPR_TYPE E = seed->* j %= 2;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)0 is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( j, 0 );
 #else
         BOOST_CHECK_EQUAL( j, 4 );
@@ -407,11 +453,11 @@
     {
         int j = 5;
 
- assertion::expression const& E = seed->* j ^= j;
+ EXPR_TYPE E = seed->* j ^= j;
         predicate_result const& res = E.evaluate();
         BOOST_CHECK( !res );
         BOOST_CHECK_EQUAL( res.message(), "(bool)0 is false" );
-#ifndef BOOST_NO_RVALUE_REFERENCES
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
         BOOST_CHECK_EQUAL( j, 0 );
 #else
         BOOST_CHECK_EQUAL( j, 5 );
@@ -421,5 +467,59 @@
 
 //____________________________________________________________________________//
 
+BOOST_AUTO_TEST_CASE( collection_comparison )
+{
+ using namespace boost::test_tools;
+ assertion::seed seed;
+
+ {
+ std::vector<int> v;
+ v.push_back( 1 );
+ v.push_back( 2 );
+ v.push_back( 3 );
+
+ std::list<int> l;
+ l.push_back( 1 );
+ l.push_back( 3 );
+ l.push_back( 2 );
+
+ EXPR_TYPE E = seed->* v == l;
+ predicate_result const& res = E.evaluate();
+ BOOST_CHECK( !res );
+ BOOST_CHECK_EQUAL( res.message(), "\nMismatch in a position 1: 2 < 3" );
+ }
+
+ {
+ std::vector<int> v;
+ v.push_back( 1 );
+
+ std::list<int> l;
+
+ EXPR_TYPE E = seed->* v == l;
+ predicate_result const& res = E.evaluate();
+ BOOST_CHECK( !res );
+ BOOST_CHECK_EQUAL( res.message(), "Collections size mismatch: 1 != 0");
+ }
+
+ {
+ std::vector<int> v;
+ v.push_back( 1 );
+ v.push_back( 2 );
+ v.push_back( 3 );
+
+ std::list<int> l;
+ l.push_back( 1 );
+ l.push_back( 3 );
+ l.push_back( 2 );
+
+ EXPR_TYPE E = seed->* v >= l;
+ predicate_result const& res = E.evaluate();
+ BOOST_CHECK( !res );
+ BOOST_CHECK_EQUAL( res.message(), "Collections size mismatch: 1 != 0");
+ }
+}
+
+//____________________________________________________________________________//
+
 // EOF
 


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