updated boost on windows
This commit is contained in:
@@ -37,6 +37,11 @@
|
||||
|
||||
#endif
|
||||
|
||||
//! Defined when the initializer_list implementation is buggy, such as for VS2013
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
# define BOOST_TEST_ERRONEOUS_INIT_LIST
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#define BOOST_TEST_DS_ERROR( msg ) BOOST_TEST_I_THROW( std::logic_error( msg ) )
|
||||
|
||||
@@ -77,7 +77,7 @@ invoke_action( Action const& action, T&& args, std::true_type /* is_tuple */ )
|
||||
|
||||
template<typename DataSet, typename Action>
|
||||
inline typename std::enable_if<monomorphic::is_dataset<DataSet>::value,void>::type
|
||||
for_each_sample( DataSet && samples,
|
||||
for_each_sample( DataSet const & samples,
|
||||
Action const& act,
|
||||
data::size_t number_of_samples = BOOST_TEST_DS_INFINITE_SIZE )
|
||||
{
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
// (C) Copyright Gennadiy Rozental 2001.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
//!@file
|
||||
//!@brief specific generators
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_DATA_MONOMORPHIC_GENERATORS_HPP_112011GER
|
||||
#define BOOST_TEST_DATA_MONOMORPHIC_GENERATORS_HPP_112011GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/data/monomorphic/generators/xrange.hpp>
|
||||
|
||||
#endif // BOOST_TEST_DATA_MONOMORPHIC_GENERATORS_HPP_112011GER
|
||||
|
||||
@@ -49,6 +49,11 @@ struct make_index_sequence<B,E,typename std::enable_if<E==B+1,void>::type> {
|
||||
typedef index_sequence<B> type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct make_index_sequence<0, 0> {
|
||||
typedef index_sequence<> type;
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
using index_sequence_for = typename make_index_sequence<0, sizeof...(T)>::type;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <boost/test/data/monomorphic/join.hpp>
|
||||
#include <boost/test/data/monomorphic/singleton.hpp>
|
||||
#include <boost/test/data/monomorphic/zip.hpp>
|
||||
#include <boost/test/data/monomorphic/delayed.hpp>
|
||||
|
||||
#endif // BOOST_TEST_DATA_MONOMORPHIC_HPP_102211GER
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ struct is_dataset<collection<C>> : mpl::true_ {};
|
||||
|
||||
//! @overload boost::unit_test::data::make()
|
||||
template<typename C>
|
||||
inline typename std::enable_if<is_forward_iterable<C>::value,monomorphic::collection<C>>::type
|
||||
inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type
|
||||
make( C&& c )
|
||||
{
|
||||
return monomorphic::collection<C>( std::forward<C>(c) );
|
||||
|
||||
124
winx64/include/boost/test/data/monomorphic/delayed.hpp
Normal file
124
winx64/include/boost/test/data/monomorphic/delayed.hpp
Normal file
@@ -0,0 +1,124 @@
|
||||
// (C) Copyright Raffi Enficiaud 2018.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
/// @file
|
||||
/// Defines a lazy/delayed dataset store
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_DATA_MONOMORPHIC_DELAYED_HPP_062018GER
|
||||
#define BOOST_TEST_DATA_MONOMORPHIC_DELAYED_HPP_062018GER
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/data/config.hpp>
|
||||
#include <boost/test/data/monomorphic/fwd.hpp>
|
||||
#include <boost/test/data/index_sequence.hpp>
|
||||
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
|
||||
namespace boost {
|
||||
namespace unit_test {
|
||||
namespace data {
|
||||
namespace monomorphic {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** delayed_dataset ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
|
||||
/// Delayed dataset
|
||||
///
|
||||
/// This dataset holds another dataset that is instanciated on demand. It is
|
||||
/// constructed with the @c data::make_delayed<dataset_t>(arg1,....) instead of the
|
||||
/// @c data::make.
|
||||
template <class dataset_t, class ...Args>
|
||||
class delayed_dataset
|
||||
{
|
||||
public:
|
||||
enum { arity = dataset_t::arity };
|
||||
using iterator = decltype(std::declval<dataset_t>().begin());
|
||||
|
||||
delayed_dataset(Args... args)
|
||||
: m_args(std::make_tuple(std::forward<Args>(args)...))
|
||||
{}
|
||||
|
||||
// Mostly for VS2013
|
||||
delayed_dataset(delayed_dataset&& b)
|
||||
: m_args(std::move(b.m_args))
|
||||
, m_dataset(std::move(b.m_dataset))
|
||||
{}
|
||||
|
||||
boost::unit_test::data::size_t size() const {
|
||||
return this->get().size();
|
||||
}
|
||||
|
||||
// iterator
|
||||
iterator begin() const {
|
||||
return this->get().begin();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
dataset_t& get() const {
|
||||
if(!m_dataset) {
|
||||
m_dataset = create(boost::unit_test::data::index_sequence_for<Args...>());
|
||||
}
|
||||
return *m_dataset;
|
||||
}
|
||||
|
||||
template<std::size_t... I>
|
||||
std::unique_ptr<dataset_t>
|
||||
create(boost::unit_test::data::index_sequence<I...>) const
|
||||
{
|
||||
return std::unique_ptr<dataset_t>{new dataset_t(std::get<I>(m_args)...)};
|
||||
}
|
||||
|
||||
std::tuple<typename std::decay<Args>::type...> m_args;
|
||||
mutable std::unique_ptr<dataset_t> m_dataset;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
//! A lazy/delayed dataset is a dataset.
|
||||
template <class dataset_t, class ...Args>
|
||||
struct is_dataset< delayed_dataset<dataset_t, Args...> > : boost::mpl::true_ {};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
} // namespace monomorphic
|
||||
|
||||
|
||||
//! Delayed dataset instanciation
|
||||
template<class dataset_t, class ...Args>
|
||||
inline typename std::enable_if<
|
||||
monomorphic::is_dataset< dataset_t >::value,
|
||||
monomorphic::delayed_dataset<dataset_t, Args...>
|
||||
>::type
|
||||
make_delayed(Args... args)
|
||||
{
|
||||
return monomorphic::delayed_dataset<dataset_t, Args...>( std::forward<Args>(args)... );
|
||||
}
|
||||
|
||||
|
||||
} // namespace data
|
||||
} // namespace unit_test
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/test/detail/enable_warnings.hpp>
|
||||
|
||||
#endif // BOOST_TEST_DATA_MONOMORPHIC_DELAYED_HPP_062018GER
|
||||
@@ -43,9 +43,6 @@ namespace monomorphic {
|
||||
|
||||
#if !defined(BOOST_TEST_DOXYGEN_DOC__)
|
||||
|
||||
template<typename T, typename Specific>
|
||||
class dataset;
|
||||
|
||||
template<typename T>
|
||||
class singleton;
|
||||
|
||||
@@ -58,6 +55,12 @@ class array;
|
||||
template<typename T>
|
||||
class init_list;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
template<class dataset_t, class ...Args>
|
||||
class delayed_dataset;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************** //
|
||||
@@ -73,6 +76,8 @@ struct is_dataset : mpl::false_ {};
|
||||
//! A reference to a dataset is a dataset
|
||||
template<typename DataSet>
|
||||
struct is_dataset<DataSet&> : is_dataset<DataSet> {};
|
||||
template<typename DataSet>
|
||||
struct is_dataset<DataSet&&> : is_dataset<DataSet> {};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
@@ -80,6 +85,18 @@ struct is_dataset<DataSet&> : is_dataset<DataSet> {};
|
||||
template<typename DataSet>
|
||||
struct is_dataset<DataSet const> : is_dataset<DataSet> {};
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
//! Helper to check if a list of types contains a dataset
|
||||
template<class DataSet, class...>
|
||||
struct has_dataset : is_dataset<DataSet> {};
|
||||
|
||||
template<class DataSet0, class DataSet1, class... DataSetTT>
|
||||
struct has_dataset<DataSet0, DataSet1, DataSetTT...>
|
||||
: std::integral_constant<bool, is_dataset<DataSet0>::value || has_dataset<DataSet1, DataSetTT...>::value>
|
||||
{};
|
||||
#endif
|
||||
|
||||
} // namespace monomorphic
|
||||
|
||||
// ************************************************************************** //
|
||||
@@ -119,7 +136,7 @@ make(DataSet&& ds)
|
||||
|
||||
//! @overload boost::unit_test::data::make()
|
||||
template<typename T>
|
||||
inline typename std::enable_if<!is_forward_iterable<T>::value &&
|
||||
inline typename std::enable_if<!is_container_forward_iterable<T>::value &&
|
||||
!monomorphic::is_dataset<T>::value &&
|
||||
!is_array<typename remove_reference<T>::type>::value,
|
||||
monomorphic::singleton<T>>::type
|
||||
@@ -129,7 +146,7 @@ make( T&& v );
|
||||
|
||||
//! @overload boost::unit_test::data::make()
|
||||
template<typename C>
|
||||
inline typename std::enable_if<is_forward_iterable<C>::value,monomorphic::collection<C>>::type
|
||||
inline typename std::enable_if<is_container_forward_iterable<C>::value,monomorphic::collection<C>>::type
|
||||
make( C&& c );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -160,6 +177,31 @@ make( std::initializer_list<T>&& );
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_TEST_ERRONEOUS_INIT_LIST)
|
||||
//! @overload boost::unit_test::data::make()
|
||||
template<class T, class ...Args>
|
||||
inline typename std::enable_if<
|
||||
!monomorphic::has_dataset<T, Args...>::value,
|
||||
monomorphic::init_list<T>
|
||||
>::type
|
||||
make( T&& arg0, Args&&... args );
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_NO_CXX11_HDR_TUPLE)
|
||||
template<class dataset_t, class ...Args>
|
||||
inline typename std::enable_if<
|
||||
monomorphic::is_dataset< dataset_t >::value,
|
||||
monomorphic::delayed_dataset<dataset_t, Args...>
|
||||
>::type
|
||||
make_delayed(Args... args);
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace result_of {
|
||||
|
||||
//! Result of the make call.
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <boost/test/data/config.hpp>
|
||||
#include <boost/test/data/monomorphic/fwd.hpp>
|
||||
|
||||
#include <boost/core/ref.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace unit_test {
|
||||
namespace data {
|
||||
|
||||
namespace {
|
||||
nfp::keyword<struct begin_t> begin;
|
||||
nfp::keyword<struct end_t> end;
|
||||
nfp::keyword<struct step_t> step;
|
||||
nfp::keyword<struct begin_t> begin BOOST_ATTRIBUTE_UNUSED;
|
||||
nfp::keyword<struct end_t> end BOOST_ATTRIBUTE_UNUSED;
|
||||
nfp::keyword<struct step_t> step BOOST_ATTRIBUTE_UNUSED;
|
||||
} // local namespace
|
||||
|
||||
} // namespace data
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include <boost/test/data/monomorphic/fwd.hpp>
|
||||
#include <boost/test/data/monomorphic/sample_merge.hpp>
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -102,7 +105,10 @@ public:
|
||||
{}
|
||||
|
||||
// dataset interface
|
||||
data::size_t size() const { return m_ds1.size() * m_ds2.size(); }
|
||||
data::size_t size() const {
|
||||
BOOST_TEST_DS_ASSERT( !m_ds1.size().is_inf() && !m_ds2.size().is_inf(), "Grid axes can't have infinite size" );
|
||||
return m_ds1.size() * m_ds2.size();
|
||||
}
|
||||
iterator begin() const { return iterator( m_ds1.begin(), m_ds2 ); }
|
||||
|
||||
private:
|
||||
@@ -138,8 +144,6 @@ inline typename boost::lazy_enable_if_c<is_dataset<DataSet1>::value && is_datase
|
||||
>::type
|
||||
operator*( DataSet1&& ds1, DataSet2&& ds2 )
|
||||
{
|
||||
BOOST_TEST_DS_ASSERT( !ds1.size().is_inf() && !ds2.size().is_inf(), "Grid axes can't have infinite size" );
|
||||
|
||||
return grid<DataSet1,DataSet2>( std::forward<DataSet1>( ds1 ), std::forward<DataSet2>( ds2 ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
#include <boost/test/data/config.hpp>
|
||||
#include <boost/test/data/monomorphic/fwd.hpp>
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -26,23 +30,35 @@ namespace data {
|
||||
namespace monomorphic {
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** array ************** //
|
||||
// ************** initializer_list ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
/// Dataset view of a C array
|
||||
/// Dataset view from an initializer_list or variadic template arguments
|
||||
///
|
||||
/// The data should be stored in the dataset, and since the elements
|
||||
/// are passed by an @c std::initializer_list , it implies a copy of
|
||||
/// the elements.
|
||||
template<typename T>
|
||||
class init_list {
|
||||
public:
|
||||
typedef T sample;
|
||||
|
||||
enum { arity = 1 };
|
||||
|
||||
typedef T const* iterator;
|
||||
typedef typename std::vector<T>::const_iterator iterator;
|
||||
|
||||
//! Constructor swallows initializer_list
|
||||
init_list( std::initializer_list<T>&& il )
|
||||
: m_data( std::forward<std::initializer_list<T>>( il ) )
|
||||
//! Constructor copies content of initializer_list
|
||||
init_list( std::initializer_list<T> il )
|
||||
: m_data( il )
|
||||
{}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_TEST_ERRONEOUS_INIT_LIST)
|
||||
//! Variadic template initialization
|
||||
template <class ...Args>
|
||||
init_list( Args&& ... args ) {
|
||||
int dummy[] = { 0, (m_data.emplace_back(std::forward<Args&&>(args)), 0)... };
|
||||
boost::ignore_unused(dummy);
|
||||
}
|
||||
#endif
|
||||
|
||||
//! dataset interface
|
||||
data::size_t size() const { return m_data.size(); }
|
||||
@@ -50,7 +66,39 @@ public:
|
||||
|
||||
private:
|
||||
// Data members
|
||||
std::initializer_list<T> m_data;
|
||||
std::vector<T> m_data;
|
||||
};
|
||||
|
||||
//! Specialization of init_list for type bool
|
||||
template <>
|
||||
class init_list<bool> {
|
||||
public:
|
||||
typedef bool sample;
|
||||
|
||||
enum { arity = 1 };
|
||||
|
||||
typedef std::vector<bool>::const_iterator iterator;
|
||||
|
||||
//! Constructor copies content of initializer_list
|
||||
init_list( std::initializer_list<bool>&& il )
|
||||
: m_data( std::forward<std::initializer_list<bool>>( il ) )
|
||||
{}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_TEST_ERRONEOUS_INIT_LIST)
|
||||
//! Variadic template initialization
|
||||
template <class ...Args>
|
||||
init_list( Args&& ... args ) : m_data{ args... }
|
||||
{ }
|
||||
#endif
|
||||
|
||||
//! dataset interface
|
||||
data::size_t size() const { return m_data.size(); }
|
||||
iterator begin() const { return m_data.begin(); }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
std::vector<bool> m_data;
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -71,6 +119,20 @@ make( std::initializer_list<T>&& il )
|
||||
return monomorphic::init_list<T>( std::forward<std::initializer_list<T>>( il ) );
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_TEST_ERRONEOUS_INIT_LIST)
|
||||
template<class T, class ...Args>
|
||||
inline typename std::enable_if<
|
||||
!monomorphic::has_dataset<T, Args...>::value,
|
||||
monomorphic::init_list<T>
|
||||
>::type
|
||||
make( T&& arg0, Args&&... args )
|
||||
{
|
||||
return monomorphic::init_list<T>( std::forward<T>(arg0), std::forward<Args>( args )... );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace data
|
||||
} // namespace unit_test
|
||||
} // namespace boost
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
#include <boost/test/data/config.hpp>
|
||||
#include <boost/test/data/monomorphic/fwd.hpp>
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -40,22 +43,33 @@ class join {
|
||||
|
||||
typedef typename dataset1_decay::iterator dataset1_iter;
|
||||
typedef typename dataset2_decay::iterator dataset2_iter;
|
||||
|
||||
using iter1_ret = decltype(*std::declval<DataSet1>().begin());
|
||||
using iter2_ret = decltype(*std::declval<DataSet2>().begin());
|
||||
|
||||
public:
|
||||
typedef typename dataset1_decay::sample sample;
|
||||
|
||||
enum { arity = dataset1_decay::arity };
|
||||
|
||||
using sample_t = typename std::conditional<
|
||||
std::is_reference<iter1_ret>::value && std::is_reference<iter2_ret>::value && std::is_same<iter1_ret, iter2_ret>::value,
|
||||
iter1_ret,
|
||||
typename std::remove_reference<iter1_ret>::type
|
||||
>::type
|
||||
;
|
||||
|
||||
struct iterator {
|
||||
// Constructor
|
||||
explicit iterator( dataset1_iter it1, dataset2_iter it2, data::size_t first_size )
|
||||
explicit iterator( dataset1_iter&& it1, dataset2_iter&& it2, data::size_t first_size )
|
||||
: m_it1( std::move( it1 ) )
|
||||
, m_it2( std::move( it2 ) )
|
||||
, m_first_size( first_size )
|
||||
{}
|
||||
|
||||
// forward iterator interface
|
||||
sample const& operator*() const { return m_first_size > 0 ? *m_it1 : *m_it2; }
|
||||
void operator++() { if( m_first_size > 0 ) { --m_first_size; ++m_it1; } else ++m_it2; }
|
||||
// The returned sample should be by value, as the operator* may return a temporary object
|
||||
sample_t operator*() const { return m_first_size > 0 ? *m_it1 : *m_it2; }
|
||||
void operator++() { if( m_first_size > 0 ) { --m_first_size; ++m_it1; } else ++m_it2; }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
|
||||
@@ -32,9 +32,11 @@ namespace monomorphic {
|
||||
/// Models a single element data set
|
||||
template<typename T>
|
||||
class singleton {
|
||||
public:
|
||||
private:
|
||||
typedef typename boost::decay<T>::type sample;
|
||||
|
||||
public:
|
||||
|
||||
enum { arity = 1 };
|
||||
|
||||
struct iterator {
|
||||
@@ -81,7 +83,7 @@ struct is_dataset<singleton<T>> : mpl::true_ {};
|
||||
|
||||
/// @overload boost::unit_test::data::make()
|
||||
template<typename T>
|
||||
inline typename std::enable_if<!is_forward_iterable<T>::value &&
|
||||
inline typename std::enable_if<!is_container_forward_iterable<T>::value &&
|
||||
!monomorphic::is_dataset<T>::value &&
|
||||
!boost::is_array<typename boost::remove_reference<T>::type>::value,
|
||||
monomorphic::singleton<T>
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
#include <boost/test/data/monomorphic/fwd.hpp>
|
||||
#include <boost/test/data/monomorphic/sample_merge.hpp>
|
||||
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
|
||||
@@ -70,33 +73,50 @@ public:
|
||||
dataset2_iter m_iter2;
|
||||
};
|
||||
|
||||
typedef typename iterator::iterator_sample sample;
|
||||
|
||||
//! Constructor
|
||||
//!
|
||||
//! The datasets are moved and not copied.
|
||||
zip( DataSet1&& ds1, DataSet2&& ds2, data::size_t size )
|
||||
zip( DataSet1&& ds1, DataSet2&& ds2/*, data::size_t size*/ )
|
||||
: m_ds1( std::forward<DataSet1>( ds1 ) )
|
||||
, m_ds2( std::forward<DataSet2>( ds2 ) )
|
||||
, m_size( size )
|
||||
//, m_size( size )
|
||||
{}
|
||||
|
||||
//! Move constructor
|
||||
zip( zip&& j )
|
||||
: m_ds1( std::forward<DataSet1>( j.m_ds1 ) )
|
||||
, m_ds2( std::forward<DataSet2>( j.m_ds2 ) )
|
||||
, m_size( j.m_size )
|
||||
//, m_size( j.m_size )
|
||||
{}
|
||||
|
||||
// dataset interface
|
||||
data::size_t size() const { return m_size; }
|
||||
data::size_t size() const { return zip_size(); }
|
||||
iterator begin() const { return iterator( m_ds1.begin(), m_ds2.begin() ); }
|
||||
|
||||
private:
|
||||
// Data members
|
||||
DataSet1 m_ds1;
|
||||
DataSet2 m_ds2;
|
||||
data::size_t m_size;
|
||||
//data::size_t m_size;
|
||||
|
||||
|
||||
//! Handles the sise of the resulting zipped dataset.
|
||||
data::size_t zip_size() const
|
||||
{
|
||||
data::size_t ds1_size = m_ds1.size();
|
||||
data::size_t ds2_size = m_ds2.size();
|
||||
|
||||
if( ds1_size == ds2_size )
|
||||
return ds1_size;
|
||||
|
||||
if( ds1_size == 1 || ds1_size.is_inf() )
|
||||
return ds2_size;
|
||||
|
||||
if( ds2_size == 1 || ds2_size.is_inf() )
|
||||
return ds1_size;
|
||||
|
||||
BOOST_TEST_DS_ERROR( "Can't zip datasets of different sizes" );
|
||||
}
|
||||
};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -107,32 +127,6 @@ struct is_dataset<zip<DataSet1,DataSet2>> : mpl::true_ {};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace ds_detail {
|
||||
|
||||
//! Handles the sise of the resulting zipped dataset.
|
||||
template<typename DataSet1, typename DataSet2>
|
||||
inline data::size_t
|
||||
zip_size( DataSet1&& ds1, DataSet2&& ds2 )
|
||||
{
|
||||
data::size_t ds1_size = ds1.size();
|
||||
data::size_t ds2_size = ds2.size();
|
||||
|
||||
if( ds1_size == ds2_size )
|
||||
return ds1_size;
|
||||
|
||||
if( ds1_size == 1 || ds1_size.is_inf() )
|
||||
return ds2_size;
|
||||
|
||||
if( ds2_size == 1 || ds2_size.is_inf() )
|
||||
return ds1_size;
|
||||
|
||||
BOOST_TEST_DS_ERROR( "Can't zip datasets of different sizes" );
|
||||
}
|
||||
|
||||
} // namespace ds_detail
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
namespace result_of {
|
||||
|
||||
//! Result type of the zip operator.
|
||||
@@ -153,8 +147,8 @@ inline typename boost::lazy_enable_if_c<is_dataset<DataSet1>::value && is_datase
|
||||
operator^( DataSet1&& ds1, DataSet2&& ds2 )
|
||||
{
|
||||
return zip<DataSet1,DataSet2>( std::forward<DataSet1>( ds1 ),
|
||||
std::forward<DataSet2>( ds2 ),
|
||||
ds_detail::zip_size( ds1, ds2 ) );
|
||||
std::forward<DataSet2>( ds2 )/*,
|
||||
ds_detail::zip_size( ds1, ds2 )*/ );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <boost/test/data/config.hpp>
|
||||
#include <boost/test/data/dataset.hpp>
|
||||
#include <boost/test/data/for_each_sample.hpp>
|
||||
#include <boost/test/tree/test_unit.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
@@ -32,13 +33,16 @@
|
||||
#include <boost/preprocessor/comparison/equal.hpp>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <boost/type_traits/is_copy_constructible.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
#include <boost/test/tools/detail/print_helper.hpp>
|
||||
#include <boost/test/utils/string_cast.hpp>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) \
|
||||
&& !defined(BOOST_TEST_DATASET_MAX_ARITY)
|
||||
# define BOOST_TEST_DATASET_MAX_ARITY 10
|
||||
@@ -122,15 +126,17 @@ public:
|
||||
// Constructor
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line, DataSet&& ds )
|
||||
: m_tc_name( ut_detail::normalize_test_case_name( tc_name ) )
|
||||
: m_dataset( std::forward<DataSet>( ds ) )
|
||||
, m_generated( false )
|
||||
, m_tc_name( ut_detail::normalize_test_case_name( tc_name ) )
|
||||
, m_tc_file( tc_file )
|
||||
, m_tc_line( tc_line )
|
||||
, m_tc_index( 0 )
|
||||
{
|
||||
data::for_each_sample( std::forward<DataSet>( ds ), *this );
|
||||
}
|
||||
{}
|
||||
test_case_gen( test_case_gen&& gen )
|
||||
: m_tc_name( gen.m_tc_name )
|
||||
: m_dataset( std::move( gen.m_dataset ) )
|
||||
, m_generated( gen.m_generated )
|
||||
, m_tc_name( gen.m_tc_name )
|
||||
, m_tc_file( gen.m_tc_file )
|
||||
, m_tc_line( gen.m_tc_line )
|
||||
, m_tc_index( gen.m_tc_index )
|
||||
@@ -138,17 +144,23 @@ public:
|
||||
{}
|
||||
#else
|
||||
test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line, DataSet const& ds )
|
||||
: m_tc_name( ut_detail::normalize_test_case_name( tc_name ) )
|
||||
, m_tc_file( tc_file )
|
||||
: m_dataset( ds )
|
||||
, m_generated( false )
|
||||
, m_tc_name( ut_detail::normalize_test_case_name( tc_name ) )
|
||||
, m_tc_file( tc_file )
|
||||
, m_tc_line( tc_line )
|
||||
, m_tc_index( 0 )
|
||||
{
|
||||
data::for_each_sample( ds, *this );
|
||||
}
|
||||
{}
|
||||
#endif
|
||||
|
||||
public:
|
||||
virtual test_unit* next() const
|
||||
{
|
||||
if(!m_generated) {
|
||||
data::for_each_sample( m_dataset, *this );
|
||||
m_generated = true;
|
||||
}
|
||||
|
||||
if( m_test_cases.empty() )
|
||||
return 0;
|
||||
|
||||
@@ -158,8 +170,10 @@ public:
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#if !defined(BOOST_TEST_DATASET_VARIADIC)
|
||||
// see BOOST_TEST_DATASET_MAX_ARITY to increase the default supported arity
|
||||
// there is also a limit on boost::bind
|
||||
#define TC_MAKE(z,arity,_) \
|
||||
template<BOOST_PP_ENUM_PARAMS(arity, typename Arg)> \
|
||||
void operator()( BOOST_PP_ENUM_BINARY_PARAMS(arity, Arg, const& arg) ) const \
|
||||
@@ -178,8 +192,8 @@ public:
|
||||
new test_case( genTestCaseName(),
|
||||
m_tc_file,
|
||||
m_tc_line,
|
||||
boost::bind( &TestCase::template test_method<Arg...>,
|
||||
boost_bind_rvalue_holder_helper(std::forward<Arg>(arg))...)));
|
||||
std::bind( &TestCase::template test_method<Arg...>,
|
||||
boost_bind_rvalue_holder_helper(std::forward<Arg>(arg))...)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -190,6 +204,8 @@ private:
|
||||
}
|
||||
|
||||
// Data members
|
||||
DataSet m_dataset;
|
||||
mutable bool m_generated;
|
||||
std::string m_tc_name;
|
||||
const_string m_tc_file;
|
||||
std::size_t m_tc_line;
|
||||
@@ -201,10 +217,10 @@ private:
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
template<typename TestCase,typename DataSet>
|
||||
test_case_gen<TestCase,DataSet>
|
||||
boost::shared_ptr<test_unit_generator> //test_case_gen<TestCase,DataSet>
|
||||
make_test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line, DataSet&& ds )
|
||||
{
|
||||
return test_case_gen<TestCase,DataSet>( tc_name, tc_file, tc_line, std::forward<DataSet>(ds) );
|
||||
return boost::shared_ptr<test_unit_generator>(new test_case_gen<TestCase,DataSet>( tc_name, tc_file, tc_line, std::forward<DataSet>(ds) ));
|
||||
}
|
||||
#else
|
||||
template<typename TestCase,typename DataSet>
|
||||
@@ -236,20 +252,29 @@ struct BOOST_PP_CAT(test_name, case) : public F { \
|
||||
template<BOOST_PP_ENUM_PARAMS(arity, typename Arg)> \
|
||||
static void test_method( BOOST_DATA_TEST_CASE_PARAMS( params ) ) \
|
||||
{ \
|
||||
BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture entry.");\
|
||||
BOOST_PP_CAT(test_name, case) t; \
|
||||
BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry."); \
|
||||
BOOST_TEST_CONTEXT( "" \
|
||||
BOOST_PP_SEQ_FOR_EACH(BOOST_DATA_TEST_CONTEXT, _, params)) \
|
||||
t._impl(BOOST_PP_SEQ_ENUM(params)); \
|
||||
BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit."); \
|
||||
{ \
|
||||
BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture ctor");\
|
||||
BOOST_PP_CAT(test_name, case) t; \
|
||||
BOOST_TEST_CHECKPOINT('"' \
|
||||
<< #test_name << "\" fixture setup"); \
|
||||
boost::unit_test::setup_conditional(t); \
|
||||
BOOST_TEST_CHECKPOINT('"' << #test_name << "\" test entry"); \
|
||||
t._impl(BOOST_PP_SEQ_ENUM(params)); \
|
||||
BOOST_TEST_CHECKPOINT('"' \
|
||||
<< #test_name << "\" fixture teardown"); \
|
||||
boost::unit_test::teardown_conditional(t); \
|
||||
BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture dtor");\
|
||||
} \
|
||||
} \
|
||||
private: \
|
||||
template<BOOST_PP_ENUM_PARAMS(arity, typename Arg)> \
|
||||
void _impl(BOOST_DATA_TEST_CASE_PARAMS( params )); \
|
||||
}; \
|
||||
\
|
||||
BOOST_AUTO_TEST_SUITE( test_name ) \
|
||||
BOOST_AUTO_TEST_SUITE( test_name, \
|
||||
*boost::unit_test::decorator::stack_decorator()) \
|
||||
\
|
||||
BOOST_AUTO_TU_REGISTRAR( BOOST_PP_CAT(test_name, case) )( \
|
||||
boost::unit_test::data::ds_detail::make_test_case_gen< \
|
||||
@@ -257,7 +282,7 @@ BOOST_AUTO_TU_REGISTRAR( BOOST_PP_CAT(test_name, case) )( \
|
||||
BOOST_STRINGIZE( test_name ), \
|
||||
__FILE__, __LINE__, \
|
||||
boost::unit_test::data::ds_detail::seed{} ->* dataset ), \
|
||||
boost::unit_test::decorator::collector::instance() ); \
|
||||
boost::unit_test::decorator::collector_t::instance() ); \
|
||||
\
|
||||
BOOST_AUTO_TEST_SUITE_END() \
|
||||
\
|
||||
|
||||
Reference in New Issue
Block a user