summaryrefslogtreecommitdiff
path: root/libs/array
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
commit08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch)
tree7a7053ceb8874b28ec4b868d4c49b500008a102e /libs/array
parentbb4dd8289b351fae6b55e303f189127a394a1edd (diff)
downloadboost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'libs/array')
-rw-r--r--libs/array/doc/array.xml4
-rw-r--r--libs/array/test/Jamfile.v211
-rw-r--r--libs/array/test/array0.cpp58
-rw-r--r--libs/array/test/array6.cpp40
-rw-r--r--libs/array/test/array_hash.cpp40
5 files changed, 59 insertions, 94 deletions
diff --git a/libs/array/doc/array.xml b/libs/array/doc/array.xml
index 8a15141579..fb1f51f6e2 100644
--- a/libs/array/doc/array.xml
+++ b/libs/array/doc/array.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<library name="Array" dirname="array" id="array" last-revision="$Date: 2012-06-14 09:01:03 -0700 (Thu, 14 Jun 2012) $">
+<library name="Array" dirname="array" id="array" last-revision="$Date$">
<libraryinfo>
<author>
<firstname>Nicolai</firstname>
@@ -68,7 +68,7 @@
<para>Note that this class is suggested to be part of the next
Technical Report, which will extend the C++ Standard (see
- <ulink url="http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</ulink>).</para>
+ <ulink url="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm</ulink>).</para>
<para>Update: <code>std::array</code> is (as of C++11) part of the C++ standard.
The differences between <code>boost::array</code> and <code>std::array</code> are minimal.
diff --git a/libs/array/test/Jamfile.v2 b/libs/array/test/Jamfile.v2
index a09ba6871b..5037474337 100644
--- a/libs/array/test/Jamfile.v2
+++ b/libs/array/test/Jamfile.v2
@@ -4,13 +4,18 @@
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 array_hash.cpp ]
+ [ run array6.cpp unit_test_framework : : : : array6 ]
+ [ run array_hash.cpp unit_test_framework : : : : array_hash ]
;
diff --git a/libs/array/test/array0.cpp b/libs/array/test/array0.cpp
index d75db760ca..c1c047e165 100644
--- a/libs/array/test/array0.cpp
+++ b/libs/array/test/array0.cpp
@@ -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 @@ void RunTests()
// 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 @@ void RunTests()
// 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 @@ void RunTests()
}
-int main()
+BOOST_AUTO_TEST_CASE( test_main )
{
RunTests< bool >();
RunTests< void * >();
RunTests< long double >();
RunTests< std::string >();
- return failed_tests;
}
diff --git a/libs/array/test/array6.cpp b/libs/array/test/array6.cpp
index 658cec6c18..3d737fd35c 100644
--- a/libs/array/test/array6.cpp
+++ b/libs/array/test/array6.cpp
@@ -10,39 +10,31 @@
#include <boost/array.hpp>
#include <algorithm>
-namespace {
-unsigned int failed_tests = 0;
-
-void fail_test( const char * reason ) {
- ++failed_tests;
- std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl;
-}
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
-template< class T >
-void RunTests()
-{
- typedef boost::array< T, 5 > test_type;
- typedef T arr[5];
- test_type test_case; // = { 1, 1, 2, 3, 5 };
+namespace {
+ template< class T >
+ void RunTests()
+ {
+ typedef boost::array< T, 5 > test_type;
+ typedef T arr[5];
+ test_type test_case; // = { 1, 1, 2, 3, 5 };
- arr &aRef = get_c_array ( test_case );
- if ( &*test_case.begin () != &aRef[0] )
- fail_test ( "Array6: Same thing not equal?(1)" );
+ arr &aRef = get_c_array ( test_case );
+ BOOST_CHECK ( &*test_case.begin () == &aRef[0] );
- const arr &caRef = get_c_array ( test_case );
- typename test_type::const_iterator iter = test_case.begin ();
- if ( &*iter != &caRef[0] )
- fail_test ( "Array6: Same thing not equal?(2)" );
-}
-
+ const arr &caRef = get_c_array ( test_case );
+ typename test_type::const_iterator iter = test_case.begin ();
+ BOOST_CHECK ( &*iter == &caRef[0] );
+ }
}
-int main()
+BOOST_AUTO_TEST_CASE( test_main )
{
RunTests< bool >();
RunTests< void * >();
RunTests< long double >();
RunTests< std::string >();
- return failed_tests;
}
diff --git a/libs/array/test/array_hash.cpp b/libs/array/test/array_hash.cpp
index 474e29cbc4..a83eeade3c 100644
--- a/libs/array/test/array_hash.cpp
+++ b/libs/array/test/array_hash.cpp
@@ -11,39 +11,33 @@
#include <algorithm>
#include <boost/functional/hash.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 RunTests()
-{
-// std::size_t hash0 = boost::hash<boost::array<T,0> > () ( boost::array<T, 0> ());
-// std::size_t hash1 = boost::hash<boost::array<T,1> > () ( boost::array<T, 1> ());
+ template< class T >
+ void RunTests()
+ {
+ // std::size_t hash0 = boost::hash<boost::array<T,0> > () ( boost::array<T, 0> ());
+ // std::size_t hash1 = boost::hash<boost::array<T,1> > () ( boost::array<T, 1> ());
- typedef boost::array< T, 5 > barr;
- typedef T arr[5];
- barr test_barr = {{ 1, 1, 2, 3, 5 }};
- arr test_arr = { 1, 1, 2, 3, 5 };
+ typedef boost::array< T, 5 > barr;
+ typedef T arr[5];
+ barr test_barr = {{ 1, 1, 2, 3, 5 }};
+ arr test_arr = { 1, 1, 2, 3, 5 };
- std::size_t bhash = boost::hash<barr> () ( test_barr );
- std::size_t ahash = boost::hash<arr> () ( test_arr );
- if ( ahash != bhash )
- fail_test ( "Array_hash: Hash-mismatch on " );
-}
+ std::size_t bhash = boost::hash<barr> () ( test_barr );
+ std::size_t ahash = boost::hash<arr> () ( test_arr );
+ BOOST_CHECK ( ahash == bhash );
+ }
}
-int main()
+BOOST_AUTO_TEST_CASE( test_main )
{
RunTests< int >();
RunTests< long >();
RunTests< long double >();
-
- return failed_tests;
}