|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81296 - trunk/libs/test/test/test_datasets_src
From: gennadiy.rozental_at_[hidden]
Date: 2012-11-11 07:07:39
Author: rogeeff
Date: 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
New Revision: 81296
URL: http://svn.boost.org/trac/boost/changeset/81296
Log:
various portability fixes to allow data driven test cases (partially) on pre c++11 compilers
Text files modified:
trunk/libs/test/test/test_datasets_src/test_array.cpp | 2 ++
trunk/libs/test/test/test_datasets_src/test_case_interface_test.cpp | 8 ++++++++
trunk/libs/test/test/test_datasets_src/test_collection.cpp | 18 ++++++++++++++----
trunk/libs/test/test/test_datasets_src/test_datasets.hpp | 18 +++++++++++++++++-
trunk/libs/test/test/test_datasets_src/test_implicit.cpp | 12 ++++++++++++
trunk/libs/test/test/test_datasets_src/test_mono_grid.cpp | 7 ++++++-
trunk/libs/test/test/test_datasets_src/test_mono_join.cpp | 13 ++++++++++++-
trunk/libs/test/test/test_datasets_src/test_mono_zip.cpp | 7 ++++++-
trunk/libs/test/test/test_datasets_src/test_random.cpp | 6 ++++++
trunk/libs/test/test/test_datasets_src/test_singleton.cpp | 20 +++++++++++++++-----
trunk/libs/test/test/test_datasets_src/test_xrange.cpp | 5 ++++-
11 files changed, 102 insertions(+), 14 deletions(-)
Modified: trunk/libs/test/test/test_datasets_src/test_array.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_array.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_array.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -30,10 +30,12 @@
int* ptr3 = arr3;
data::for_each_sample( data::make( arr3 ), check_arg_type<int>() );
+#ifndef BOOST_NO_CXX11_LAMBDAS
int c = 0;
data::for_each_sample( data::make( arr3 ), [&c,ptr3](int i) {
BOOST_TEST( i == ptr3[c++] );
});
+#endif
invocation_count ic;
Modified: trunk/libs/test/test/test_datasets_src/test_case_interface_test.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_case_interface_test.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_case_interface_test.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -14,6 +14,9 @@
// Boost.Test
#include <boost/test/unit_test.hpp>
+
+#if BOOST_PP_VARIADICS
+
#include <boost/test/data/test_case.hpp>
#include <boost/test/data/monomorphic.hpp>
namespace data=boost::unit_test::data;
@@ -42,6 +45,8 @@
//____________________________________________________________________________//
+#ifndef BOOST_NO_CXX11_DECLTYPE
+
int samples3[] = {7,9};
int index3 = 0;
@@ -94,4 +99,7 @@
//____________________________________________________________________________//
+#endif // BOOST_NO_CXX11_DECLTYPE
+#endif // BOOST_PP_VARIADICS
+
// EOF
Modified: trunk/libs/test/test/test_datasets_src/test_collection.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_collection.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_collection.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -51,6 +51,7 @@
samples1.push_back(567);
samples1.push_back(13);
+#ifndef BOOST_NO_CXX11_LAMBDAS
int c = 0;
data::for_each_sample( data::make( samples1 ), [&c,samples1](int i) {
BOOST_TEST( i == samples1[c++] );
@@ -65,32 +66,41 @@
data::for_each_sample( data::make( samples2 ), [&it](char const* str ) {
BOOST_TEST( str == *it++ );
});
+#endif
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ int exp_copy_count = 0;
+#else
+ int exp_copy_count = 4;
+#endif
copy_count::value() = 0;
data::for_each_sample( data::make( std::vector<copy_count>( 2 ) ), check_arg_type<copy_count>() );
- BOOST_TEST( copy_count::value() == 0 );
+ BOOST_TEST( copy_count::value() == exp_copy_count );
copy_count::value() = 0;
std::vector<copy_count> samples3( 2 );
data::for_each_sample( data::make( samples3 ), check_arg_type<copy_count>() );
- BOOST_TEST( copy_count::value() == 0 );
+ BOOST_TEST( copy_count::value() == exp_copy_count );
copy_count::value() = 0;
std::vector<copy_count> const samples4( 2 );
data::for_each_sample( data::make( samples4 ), check_arg_type<copy_count>() );
- BOOST_TEST( copy_count::value() == 0 );
+ BOOST_TEST( copy_count::value() == exp_copy_count );
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
copy_count::value() = 0;
auto ds1 = data::make( make_copy_count_collection() );
BOOST_TEST( ds1.size() == 3 );
data::for_each_sample( ds1, check_arg_type<copy_count>() );
- BOOST_TEST( copy_count::value() == 0 );
+ BOOST_TEST( copy_count::value() == exp_copy_count );
copy_count::value() = 0;
auto ds2 = data::make( make_copy_count_const_collection() );
BOOST_TEST( ds2.size() == 3 );
data::for_each_sample( ds2, check_arg_type<copy_count>() );
BOOST_TEST( copy_count::value() == 3 ); // !! ?? no const rvalue rev constructor for std::list
+#endif
}
//____________________________________________________________________________//
Modified: trunk/libs/test/test/test_datasets_src/test_datasets.hpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_datasets.hpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_datasets.hpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -27,15 +27,18 @@
public:
copy_count() {}
copy_count( copy_count const& ) { value()++; }
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
copy_count( copy_count&& ) {}
copy_count( copy_count const&& ) {}
+#endif
// ~copy_count() { std::cout << "~copy_count" << std::endl; }
static int& value() { static int s_value; return s_value; };
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
static copy_count make() { return std::move( copy_count() ); }
static copy_count const make_const() { return std::move( copy_count() ); }
-
+#endif
};
//____________________________________________________________________________//
@@ -51,6 +54,8 @@
//____________________________________________________________________________//
+#ifndef BOOST_NO_CXX11_HDR_TUPLE
+
template<typename T1, typename T2>
struct check_arg_type<std::tuple<T1,T2>> {
template<typename S1, typename S2>
@@ -76,6 +81,8 @@
//____________________________________________________________________________//
+#endif // BOOST_NO_CXX11_HDR_TUPLE
+
template<typename T>
struct check_arg_type_like {
template<typename S>
@@ -87,6 +94,8 @@
//____________________________________________________________________________//
+#ifndef BOOST_NO_CXX11_HDR_TUPLE
+
template<typename T1, typename T2>
struct check_arg_type_like<std::tuple<T1,T2>> {
template<typename S1, typename S2>
@@ -112,6 +121,9 @@
//____________________________________________________________________________//
+#endif // BOOST_NO_CXX11_HDR_TUPLE
+
+
struct invocation_count {
invocation_count() : m_value( 0 ) {}
@@ -149,6 +161,8 @@
//____________________________________________________________________________//
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+
inline std::vector<copy_count>
make_copy_count_collection()
{
@@ -165,4 +179,6 @@
//____________________________________________________________________________//
+#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
+
#endif // BOOST_TEST_TEST_DATASETS_HPP_120511ER
Modified: trunk/libs/test/test/test_datasets_src/test_implicit.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_implicit.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_implicit.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -46,7 +46,11 @@
copy_count::value() = 0;
std::vector<copy_count> samples1( 2 );
data::for_each_sample( samples1, check_arg_type<copy_count>() );
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_TEST( copy_count::value() == 0 );
+#else
+ BOOST_TEST( copy_count::value() == 4 );
+#endif
copy_count::value() = 0;
copy_count samples2[] = { copy_count(), copy_count() };
@@ -58,24 +62,32 @@
BOOST_AUTO_TEST_CASE( test_implicit_join )
{
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
auto ds = data::make( 5 );
BOOST_TEST( (1 + ds).size() == 2 );
BOOST_TEST( (ds + 1).size() == 2 );
+#endif
+#ifndef BOOST_NO_CXX11_DECLTYPE
BOOST_TEST( (1 + data::make( 5 )).size() == 2 );
BOOST_TEST( (data::make( 5 ) + 1).size() == 2 );
+#endif
}
//____________________________________________________________________________//
BOOST_AUTO_TEST_CASE( test_implicit_zip )
{
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
auto ds = data::make( 5 );
BOOST_TEST( (1 ^ ds).size() == 1 );
BOOST_TEST( (ds ^ 1).size() == 1 );
+#endif
+#ifndef BOOST_NO_CXX11_HDR_TUPLE
BOOST_TEST( (1 ^ data::make( 5 )).size() == 1 );
BOOST_TEST( (data::make( 5 ) ^ 1).size() == 1 );
+#endif
}
//____________________________________________________________________________//
Modified: trunk/libs/test/test/test_datasets_src/test_mono_grid.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_mono_grid.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_mono_grid.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -9,11 +9,14 @@
//
// Version : $Revision$
//
-// Description : tests monomorphic join
+// Description : tests monomorphic grid
// ***************************************************************************
// Boost.Test
#include <boost/test/unit_test.hpp>
+
+#ifndef BOOST_NO_CXX11_HDR_TUPLE
+
#include <boost/test/data/monomorphic/grid.hpp>
#include <boost/test/data/monomorphic/singleton.hpp>
#include <boost/test/data/monomorphic/array.hpp>
@@ -140,4 +143,6 @@
//____________________________________________________________________________//
+#endif // BOOST_NO_CXX11_HDR_TUPLE
+
// EOF
Modified: trunk/libs/test/test/test_datasets_src/test_mono_join.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_mono_join.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_mono_join.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -35,6 +35,7 @@
BOOST_TEST( (data::make( std::vector<int>(2) ) + data::make( 1 ) + data::make( arr2 ) + data::make( 17 )).size() == 6 );
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
int expected[] = {1,2,5,7,19,37};
int* exp = expected;
int c = 0;
@@ -72,24 +73,33 @@
data::for_each_sample( samples3, [&c,exp](int i) {
BOOST_TEST( i == exp[c++] );
});
+#endif
copy_count::value() = 0;
data::for_each_sample( data::make( copy_count() ) + data::make( copy_count() ), check_arg_type<copy_count>() );
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_TEST( copy_count::value() == 0 );
+#endif
copy_count::value() = 0;
data::for_each_sample( data::make( copy_count() ) + data::make( copy_count() ) + data::make( copy_count() ), check_arg_type<copy_count>() );
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_TEST( copy_count::value() == 0 );
+#endif
copy_count::value() = 0;
data::for_each_sample( data::make( copy_count() ) + (data::make( copy_count() ) + data::make( copy_count() )), check_arg_type<copy_count>() );
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_TEST( copy_count::value() == 0 );
-
+#endif
copy_count::value() = 0;
data::for_each_sample( (data::make( copy_count() ) + data::make( copy_count() )) +
(data::make( copy_count() ) + data::make( copy_count() )), check_arg_type<copy_count>() );
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
BOOST_TEST( copy_count::value() == 0 );
+#endif
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
auto ds1 = data::make( copy_count() );
auto const ds2 = data::make( copy_count() );
@@ -131,6 +141,7 @@
BOOST_TEST( ds3.size() == 6 );
data::for_each_sample( ds3, check_arg_type<copy_count>() );
BOOST_TEST( copy_count::value() == 0 );
+#endif
}
//____________________________________________________________________________//
Modified: trunk/libs/test/test/test_datasets_src/test_mono_zip.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_mono_zip.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_mono_zip.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -9,11 +9,14 @@
//
// Version : $Revision$
//
-// Description : tests monomorphic join
+// Description : tests monomorphic zip
// ***************************************************************************
// Boost.Test
#include <boost/test/unit_test.hpp>
+
+#ifndef BOOST_NO_CXX11_HDR_TUPLE
+
#include <boost/test/data/monomorphic/zip.hpp>
#include <boost/test/data/monomorphic/singleton.hpp>
#include <boost/test/data/monomorphic/array.hpp>
@@ -138,4 +141,6 @@
//____________________________________________________________________________//
+#endif // BOOST_NO_CXX11_HDR_TUPLE
+
// EOF
Modified: trunk/libs/test/test/test_datasets_src/test_random.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_random.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_random.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -14,6 +14,9 @@
// Boost.Test
#include <boost/test/unit_test.hpp>
+
+#ifndef BOOST_NO_0X_HDR_RANDOM
+
#include <boost/test/data/monomorphic/generators/random.hpp>
#include <boost/test/data/monomorphic/zip.hpp>
#include <boost/test/data/monomorphic/array.hpp>
@@ -131,4 +134,7 @@
//____________________________________________________________________________//
+#endif // BOOST_NO_0X_HDR_RANDOM
+
+
// EOF
Modified: trunk/libs/test/test/test_datasets_src/test_singleton.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_singleton.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_singleton.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -46,33 +46,43 @@
data::for_each_sample( data::make( 2 ), ic, 0 );
BOOST_TEST( ic.m_value == 0 );
+#ifndef BOOST_NO_CXX11_LAMBDAS
data::for_each_sample( data::make( 2 ), [] (int s) {
BOOST_TEST( s == 2 );
});
+#endif
+
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
+ int exp_copy_count = 0;
+#else
+ int exp_copy_count = 1;
+#endif
copy_count::value() = 0;
data::for_each_sample( data::make( copy_count() ), check_arg_type<copy_count>() );
- BOOST_TEST( copy_count::value() == 0 );
+ BOOST_TEST( copy_count::value() == exp_copy_count );
copy_count::value() = 0;
copy_count cc1;
data::for_each_sample( data::make( cc1 ), check_arg_type<copy_count>() );
- BOOST_TEST( copy_count::value() == 0 );
+ BOOST_TEST( copy_count::value() == exp_copy_count );
copy_count::value() = 0;
copy_count const cc2;
data::for_each_sample( data::make( cc2 ), check_arg_type<copy_count>() );
- BOOST_TEST( copy_count::value() == 0 );
+ BOOST_TEST( copy_count::value() == exp_copy_count );
+#ifndef BOOST_NO_CXX11_AUTO_DECLARATIONS
copy_count::value() = 0;
auto ds1 = data::make( copy_count::make() );
data::for_each_sample( ds1, check_arg_type<copy_count>() );
- BOOST_TEST( copy_count::value() == 0 );
+ BOOST_TEST( copy_count::value() == exp_copy_count );
copy_count::value() = 0;
auto ds2 = data::make( copy_count::make_const() );
data::for_each_sample( ds2, check_arg_type<copy_count>() );
- BOOST_TEST( copy_count::value() == 0 );
+ BOOST_TEST( copy_count::value() == exp_copy_count );
+#endif
}
//____________________________________________________________________________//
Modified: trunk/libs/test/test/test_datasets_src/test_xrange.cpp
==============================================================================
--- trunk/libs/test/test/test_datasets_src/test_xrange.cpp (original)
+++ trunk/libs/test/test/test_datasets_src/test_xrange.cpp 2012-11-11 07:07:37 EST (Sun, 11 Nov 2012)
@@ -46,8 +46,8 @@
BOOST_TEST( data::xrange<int>(( data::begin = 9, data::end = 15 )).size() == 6 );
BOOST_TEST( data::xrange<double>(( data::step = 0.5, data::end = 3 )).size() == 6 );
+#ifndef BOOST_NO_CXX11_LAMBDAS
int c = 0;
-
data::for_each_sample( data::xrange( 3 ), [&c](int a) {
BOOST_TEST( a == c++ );
});
@@ -57,10 +57,12 @@
BOOST_TEST( a == c );
c += 2;
});
+#endif
}
BOOST_AUTO_TEST_CASE( test_range_join )
{
+#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
auto ds = data::xrange( 1, 4 ) + data::xrange( 7, 11 );
BOOST_TEST( ds.size() == 7 );
@@ -77,6 +79,7 @@
data::for_each_sample( ds, [&c,exp](int a) {
BOOST_TEST( a == exp[c++] );
});
+#endif
}
//____________________________________________________________________________//
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