Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82822 - trunk/libs/array/test
From: marshall_at_[hidden]
Date: 2013-02-11 12:16:56


Author: marshall
Date: 2013-02-11 12:16:55 EST (Mon, 11 Feb 2013)
New Revision: 82822
URL: http://svn.boost.org/trac/boost/changeset/82822

Log:
Update Boost.Array tests to use newer Boost.Test features
Text files modified:
   trunk/libs/array/test/Jamfile.v2 | 13 ++++++--
   trunk/libs/array/test/array0.cpp | 58 +++++++++++----------------------------
   trunk/libs/array/test/array6.cpp | 7 ++--
   trunk/libs/array/test/array7.cpp | 6 ++--
   trunk/libs/array/test/array_getfail1.cpp | 7 ++--
   trunk/libs/array/test/array_getfail2.cpp | 6 ++--
   trunk/libs/array/test/array_hash.cpp | 7 ++--
   7 files changed, 40 insertions(+), 64 deletions(-)

Modified: trunk/libs/array/test/Jamfile.v2
==============================================================================
--- trunk/libs/array/test/Jamfile.v2 (original)
+++ trunk/libs/array/test/Jamfile.v2 2013-02-11 12:16:55 EST (Mon, 11 Feb 2013)
@@ -4,16 +4,21 @@
 
 import testing ;
 
+alias unit_test_framework
+ : # sources
+ /boost//unit_test_framework
+ ;
+
 test-suite array :
- [ run array0.cpp ]
+ [ run array0.cpp unit_test_framework : : : : array0 ]
     [ run array1.cpp ]
     [ run array2.cpp ]
     [ run array3.cpp ]
     [ run array4.cpp ]
     [ run array5.cpp ]
- [ run array6.cpp ]
- [ run array7.cpp ]
+ [ run array6.cpp unit_test_framework : : : : array6 ]
+ [ run array7.cpp unit_test_framework : : : : array7 ]
     [ compile-fail array_getfail1.cpp ]
     [ compile-fail array_getfail2.cpp ]
- [ run array_hash.cpp ]
+ [ run array_hash.cpp unit_test_framework : : : : array_hash ]
     ;

Modified: trunk/libs/array/test/array0.cpp
==============================================================================
--- trunk/libs/array/test/array0.cpp (original)
+++ trunk/libs/array/test/array0.cpp 2013-02-11 12:16:55 EST (Mon, 11 Feb 2013)
@@ -9,18 +9,15 @@
 #include <iostream>
 #include <boost/array.hpp>
 
-namespace {
-unsigned int failed_tests = 0;
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
 
-void fail_test( const char * reason ) {
- ++failed_tests;
- std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl;
-}
+namespace {
 
 template< class T >
 void BadValue( const T & )
 {
- fail_test( "Unexpected value" );
+ BOOST_CHECK ( false );
 }
 
 template< class T >
@@ -36,46 +33,24 @@
 
     // front/back and operator[] must compile, but calling them is undefined
     // Likewise, all tests below should evaluate to false, avoiding undefined behaviour
- if( !test_case.empty() ) {
- BadValue( test_case.front() );
- }
-
- if( !const_test_case.empty() ) {
- BadValue( const_test_case.back() );
- }
-
- if( test_case.size() > 0 ) {
- BadValue( test_case[ 0 ] );
- }
+ BOOST_CHECK ( test_case.empty());
+ BOOST_CHECK ( const_test_case.empty());
 
- if( const_test_case.max_size() > 0 ) {
- BadValue( const_test_case[ 0 ] );
- }
+ BOOST_CHECK ( test_case.size() == 0 );
+ BOOST_CHECK ( const_test_case.size() == 0 );
 
     // Assert requirements of TR1 6.2.2.4
- if( test_case.begin() != test_case.end() ) {
- fail_test( "Not an empty range" );
- }
- if( test_case.cbegin() != test_case.cend() ) {
- fail_test( "Not an empty range" );
- }
- if( const_test_case.begin() != const_test_case.end() ) {
- fail_test( "Not an empty range" );
- }
- if( const_test_case.cbegin() != const_test_case.cend() ) {
- fail_test( "Not an empty range" );
- }
-
- if( test_case.begin() == const_test_case.begin() ) {
- fail_test( "iterators for different containers are not distinct" );
- }
+ BOOST_CHECK ( test_case.begin() == test_case.end());
+ BOOST_CHECK ( test_case.cbegin() == test_case.cend());
+ BOOST_CHECK ( const_test_case.begin() == const_test_case.end());
+ BOOST_CHECK ( const_test_case.cbegin() == const_test_case.cend());
 
+ BOOST_CHECK ( test_case.begin() != const_test_case.begin() );
     if( test_case.data() == const_test_case.data() ) {
     // Value of data is unspecified in TR1, so no requirement this test pass or fail
     // However, it must compile!
     }
 
-
     // Check can safely use all iterator types with std algorithms
     std::for_each( test_case.begin(), test_case.end(), BadValue< T > );
     std::for_each( test_case.rbegin(), test_case.rend(), BadValue< T > );
@@ -87,12 +62,12 @@
     // Check swap is well formed
     std::swap( test_case, test_case );
 
- // Check assigment operator and overloads are well formed
+ // Check assignment operator and overloads are well formed
     test_case = const_test_case;
 
     // Confirm at() throws the std lib defined exception
     try {
- BadValue( test_case.at( 0 ) );
+ BadValue( test_case.at( 0 ));
     } catch ( const std::out_of_range & ) {
     }
 
@@ -104,12 +79,11 @@
 
 }
 
-int main()
+BOOST_AUTO_TEST_CASE( test_main )
 {
     RunTests< bool >();
     RunTests< void * >();
     RunTests< long double >();
     RunTests< std::string >();
- return failed_tests;
 }
 

Modified: trunk/libs/array/test/array6.cpp
==============================================================================
--- trunk/libs/array/test/array6.cpp (original)
+++ trunk/libs/array/test/array6.cpp 2013-02-11 12:16:55 EST (Mon, 11 Feb 2013)
@@ -10,8 +10,8 @@
 #include <boost/array.hpp>
 #include <algorithm>
 
-#include <boost/test/included/test_exec_monitor.hpp>
-
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
 
 namespace {
     template< class T >
@@ -30,12 +30,11 @@
     }
 }
 
-int test_main( int , char* [] )
+BOOST_AUTO_TEST_CASE( test_main )
 {
     RunTests< bool >();
     RunTests< void * >();
     RunTests< long double >();
     RunTests< std::string >();
- return 0;
 }
 

Modified: trunk/libs/array/test/array7.cpp
==============================================================================
--- trunk/libs/array/test/array7.cpp (original)
+++ trunk/libs/array/test/array7.cpp 2013-02-11 12:16:55 EST (Mon, 11 Feb 2013)
@@ -13,7 +13,8 @@
 #include <array>
 #endif
 
-#include <boost/test/included/test_exec_monitor.hpp>
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
 
 namespace {
 
@@ -49,7 +50,7 @@
 
 }
 
-int test_main( int , char* [] )
+BOOST_AUTO_TEST_CASE( test_main )
 {
     RunBoostTests< bool >();
     RunBoostTests< void * >();
@@ -62,6 +63,5 @@
     RunStdTests< long double >();
     RunStdTests< std::string >();
 #endif
- return 0;
 }
 

Modified: trunk/libs/array/test/array_getfail1.cpp
==============================================================================
--- trunk/libs/array/test/array_getfail1.cpp (original)
+++ trunk/libs/array/test/array_getfail1.cpp 2013-02-11 12:16:55 EST (Mon, 11 Feb 2013)
@@ -16,7 +16,8 @@
 #include <array>
 #endif
 
-#include <boost/test/included/test_exec_monitor.hpp>
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
 
 namespace {
 
@@ -35,9 +36,8 @@
 
 }
 
-int test_main( int , char* [] )
+BOOST_AUTO_TEST_CASE( test_main )
 {
-
 #ifndef BOOST_NO_CXX11_HDR_ARRAY
     RunStdTests< bool >();
     RunStdTests< void * >();
@@ -46,6 +46,5 @@
 #else
         BOOST_STATIC_ASSERT ( false ); // fail on C++03 systems.
 #endif
- return 0;
 }
 

Modified: trunk/libs/array/test/array_getfail2.cpp
==============================================================================
--- trunk/libs/array/test/array_getfail2.cpp (original)
+++ trunk/libs/array/test/array_getfail2.cpp 2013-02-11 12:16:55 EST (Mon, 11 Feb 2013)
@@ -13,7 +13,8 @@
 #include <array>
 #endif
 
-#include <boost/test/included/test_exec_monitor.hpp>
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
 
 namespace {
 
@@ -46,7 +47,7 @@
 
 }
 
-int test_main( int , char* [] )
+BOOST_AUTO_TEST_CASE( test_main )
 {
     RunBoostTests< bool >();
     RunBoostTests< void * >();
@@ -59,6 +60,5 @@
     RunStdTests< long double >();
     RunStdTests< std::string >();
 #endif
- return 0;
 }
 

Modified: trunk/libs/array/test/array_hash.cpp
==============================================================================
--- trunk/libs/array/test/array_hash.cpp (original)
+++ trunk/libs/array/test/array_hash.cpp 2013-02-11 12:16:55 EST (Mon, 11 Feb 2013)
@@ -11,7 +11,8 @@
 #include <algorithm>
 #include <boost/functional/hash.hpp>
 
-#include <boost/test/included/test_exec_monitor.hpp>
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
 
 namespace {
 
@@ -33,12 +34,10 @@
 
 }
 
-int test_main( int , char* [] )
+BOOST_AUTO_TEST_CASE( test_main )
 {
     RunTests< int >();
     RunTests< long >();
     RunTests< long double >();
-
- return 0;
 }
 


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