mirror of
https://github.com/boostorg/range.git
synced 2025-07-29 20:37:25 +02:00
Boost.RangeEx merged into Boost.Range
[SVN r60897]
This commit is contained in:
49
test/test_function/check_equal_fn.hpp
Normal file
49
test/test_function/check_equal_fn.hpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to 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)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_TEST_FUNCTIONS_CHECK_EQUAL_FN_HPP_INCLUDED
|
||||
#define BOOST_RANGE_TEST_FUNCTIONS_CHECK_EQUAL_FN_HPP_INCLUDED
|
||||
|
||||
#include "counted_function.hpp"
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_test_function
|
||||
{
|
||||
template< class Collection >
|
||||
class check_equal_fn : private counted_function
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Collection::const_iterator iter_t;
|
||||
public:
|
||||
explicit check_equal_fn( const Collection& c )
|
||||
: m_it(boost::begin(c)), m_last(boost::end(c)) {}
|
||||
|
||||
using counted_function::invocation_count;
|
||||
|
||||
void operator()(int x) const
|
||||
{
|
||||
invoked();
|
||||
BOOST_CHECK( m_it != m_last );
|
||||
if (m_it != m_last)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( *m_it, x );
|
||||
++m_it;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
mutable iter_t m_it;
|
||||
iter_t m_last;
|
||||
};
|
||||
|
||||
} // namespace range_test_function
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
40
test/test_function/counted_function.hpp
Normal file
40
test/test_function/counted_function.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to 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)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_TEST_FUNCTION_COUNTED_FUNCTION_HPP_INCLUDED
|
||||
#define BOOST_RANGE_TEST_FUNCTION_COUNTED_FUNCTION_HPP_INCLUDED
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_test_function
|
||||
{
|
||||
|
||||
class counted_function
|
||||
{
|
||||
public:
|
||||
counted_function() : m_count(0u) {}
|
||||
|
||||
void invoked() const
|
||||
{
|
||||
++m_count;
|
||||
}
|
||||
|
||||
// Return the number of times that this function object
|
||||
// has been invoked.
|
||||
unsigned int invocation_count() const { return m_count; }
|
||||
|
||||
private:
|
||||
mutable unsigned int m_count;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // include guard
|
33
test/test_function/equal_to_x.hpp
Normal file
33
test/test_function/equal_to_x.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to 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)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_EQUAL_TO_X_HPP_INCLUDED
|
||||
#define BOOST_RANGE_TEST_TEST_FUNCTION_EQUAL_TO_X_HPP_INCLUDED
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_test_function
|
||||
{
|
||||
template<class Arg>
|
||||
struct equal_to_x
|
||||
{
|
||||
typedef bool result_type;
|
||||
typedef Arg argument_type;
|
||||
|
||||
explicit equal_to_x(Arg x) : m_x(x) {}
|
||||
bool operator()(Arg x) const { return x == m_x; }
|
||||
|
||||
private:
|
||||
Arg m_x;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // include guard
|
29
test/test_function/false_predicate.hpp
Normal file
29
test/test_function/false_predicate.hpp
Normal file
@ -0,0 +1,29 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to 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)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_FALSE_PREDICATE_HPP_INCLUDED
|
||||
#define BOOST_RANGE_TEST_TEST_FUNCTION_FALSE_PREDICATE_HPP_INCLUDED
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_test_function
|
||||
{
|
||||
struct false_predicate
|
||||
{
|
||||
typedef bool result_type;
|
||||
|
||||
bool operator()() const { return false; }
|
||||
template<class Arg> bool operator()(Arg) const { return false; }
|
||||
template<class Arg1, class Arg2> bool operator()(Arg1,Arg2) const { return false; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // include guard
|
32
test/test_function/greater_than_x.hpp
Normal file
32
test/test_function/greater_than_x.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to 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)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_TEST_FUNCTION_GREATER_THAN_X_HPP_INCLUDED
|
||||
#define BOOST_RANGE_TEST_FUNCTION_GREATER_THAN_X_HPP_INCLUDED
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_test_function
|
||||
{
|
||||
template< class Number >
|
||||
struct greater_than_x
|
||||
{
|
||||
typedef bool result_type;
|
||||
typedef Number argument_type;
|
||||
|
||||
explicit greater_than_x(Number x) : m_x(x) {}
|
||||
bool operator()(Number x) const { return x > m_x; }
|
||||
private:
|
||||
Number m_x;
|
||||
};
|
||||
} // namespace range_test_function
|
||||
} // namespace boost
|
||||
|
||||
#endif // include guard
|
32
test/test_function/multiply_by_x.hpp
Normal file
32
test/test_function/multiply_by_x.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2009. Use, modification and
|
||||
// distribution is subject to 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)
|
||||
//
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_TEST_TEST_FUNCTION_MULTIPLY_BY_X_HPP_INCLUDED
|
||||
#define BOOST_RANGE_TEST_TEST_FUNCTION_MULTIPLY_BY_X_HPP_INCLUDED
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_test_function
|
||||
{
|
||||
template< class Arg >
|
||||
struct multiply_by_x
|
||||
{
|
||||
typedef Arg result_type;
|
||||
typedef Arg argument_type;
|
||||
|
||||
explicit multiply_by_x(Arg x) : m_x(x) {}
|
||||
Arg operator()(Arg x) const { return x * m_x; }
|
||||
private:
|
||||
Arg m_x;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // include guard
|
Reference in New Issue
Block a user