forked from boostorg/core
Compare commits
9 Commits
feature/ad
...
boost-1.73
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
690514e87c | ||
|
|
5a5d2adda0 | ||
|
|
10c01d0d56 | ||
|
|
27d8ef1286 | ||
|
|
b5c2726d1b | ||
|
|
0eecbda0b1 | ||
|
|
2a471c3417 | ||
|
|
5ca752323f | ||
|
|
13e9d3d4d9 |
@@ -139,8 +139,7 @@ public:
|
||||
|
||||
using empty_::empty_value;
|
||||
|
||||
BOOST_INLINE_VARIABLE
|
||||
BOOST_CONSTEXPR_OR_CONST empty_init_t empty_init = empty_init_t();
|
||||
BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
|
||||
|
||||
} /* boost */
|
||||
|
||||
|
||||
@@ -93,12 +93,21 @@ inline int& test_errors()
|
||||
return test_results().errors();
|
||||
}
|
||||
|
||||
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
|
||||
inline bool test_impl(char const * expr, char const * file, int line, char const * function, bool v)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr << "' failed in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
if( v )
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr << "' failed in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void error_impl(char const * msg, char const * file, int line, char const * function)
|
||||
@@ -184,13 +193,14 @@ struct lw_test_ge {
|
||||
};
|
||||
|
||||
template<class BinaryPredicate, class T, class U>
|
||||
inline void test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
|
||||
inline bool test_with_impl(BinaryPredicate pred, char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function,
|
||||
T const & t, U const & u)
|
||||
{
|
||||
if( pred(t, u) )
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -199,15 +209,17 @@ inline void test_with_impl(BinaryPredicate pred, char const * expr1, char const
|
||||
<< "' ('" << test_output_impl(t) << "' " << pred.op() << " '" << test_output_impl(u)
|
||||
<< "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
|
||||
inline bool test_cstr_eq_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, char const * const t, char const * const u )
|
||||
{
|
||||
if( std::strcmp(t, u) == 0 )
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -215,15 +227,17 @@ inline void test_cstr_eq_impl( char const * expr1, char const * expr2,
|
||||
<< file << "(" << line << "): test '" << expr1 << " == " << expr2 << "' ('" << t
|
||||
<< "' == '" << u << "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
|
||||
inline bool test_cstr_ne_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, char const * const t, char const * const u )
|
||||
{
|
||||
if( std::strcmp(t, u) != 0 )
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -231,11 +245,12 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2,
|
||||
<< file << "(" << line << "): test '" << expr1 << " != " << expr2 << "' ('" << t
|
||||
<< "' != '" << u << "') failed in function '" << function << "'" << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2>
|
||||
void test_all_eq_impl(FormattedOutputFunction& output,
|
||||
bool test_all_eq_impl(FormattedOutputFunction& output,
|
||||
char const * file, int line, char const * function,
|
||||
InputIterator1 first_begin, InputIterator1 first_end,
|
||||
InputIterator2 second_begin, InputIterator2 second_end)
|
||||
@@ -294,16 +309,18 @@ void test_all_eq_impl(FormattedOutputFunction& output,
|
||||
if (error_count == 0)
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
output << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template<class FormattedOutputFunction, class InputIterator1, class InputIterator2, typename BinaryPredicate>
|
||||
void test_all_with_impl(FormattedOutputFunction& output,
|
||||
bool test_all_with_impl(FormattedOutputFunction& output,
|
||||
char const * file, int line, char const * function,
|
||||
InputIterator1 first_begin, InputIterator1 first_end,
|
||||
InputIterator2 second_begin, InputIterator2 second_end,
|
||||
@@ -363,11 +380,13 @@ void test_all_with_impl(FormattedOutputFunction& output,
|
||||
if (error_count == 0)
|
||||
{
|
||||
test_results();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
output << std::endl;
|
||||
++test_results().errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,7 +426,7 @@ inline int report_errors()
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_TEST(expr) ((expr)? (void)::boost::detail::test_results(): ::boost::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
|
||||
#define BOOST_TEST(expr) ( ::boost::detail::test_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, (expr)? true: false) )
|
||||
#define BOOST_TEST_NOT(expr) BOOST_TEST(!(expr))
|
||||
|
||||
#define BOOST_ERROR(msg) ( ::boost::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
@@ -13,6 +13,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <memory>
|
||||
#else
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <cstddef>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdlib>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ compile ignore_unused_test.cpp
|
||||
: <warnings>extra
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
<toolset>msvc::<warnings-as-errors>on ;
|
||||
<toolset>msvc:<warnings-as-errors>on ;
|
||||
|
||||
run sp_typeinfo_test.cpp ;
|
||||
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
|
||||
@@ -107,6 +107,8 @@ run-fail lightweight_test_le_fail.cpp ;
|
||||
run-fail lightweight_test_gt_fail.cpp ;
|
||||
run-fail lightweight_test_ge_fail.cpp ;
|
||||
|
||||
run lightweight_test_bool.cpp ;
|
||||
|
||||
run is_same_test.cpp ;
|
||||
|
||||
run typeinfo_test.cpp ;
|
||||
|
||||
63
test/lightweight_test_bool.cpp
Normal file
63
test/lightweight_test_bool.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST( BOOST_TEST( true ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST( false ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_NOT( false ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_NOT( true ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_EQ( 1, 1 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_EQ( 1, 2 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_NE( 1, 2 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_NE( 1, 1 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_LT( 1, 2 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_LT( 1, 1 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_LE( 1, 1 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_LE( 2, 1 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_GT( 2, 1 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_GT( 1, 1 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_GE( 1, 1 ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_GE( 1, 2 ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_CSTR_EQ( "1", "1" ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_CSTR_EQ( "1", "2" ) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_CSTR_NE( "1", "2" ) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_CSTR_NE( "1", "1" ) );
|
||||
|
||||
std::vector<int> v1;
|
||||
v1.push_back( 1 );
|
||||
|
||||
std::vector<int> v2;
|
||||
|
||||
BOOST_TEST( BOOST_TEST_ALL_EQ(v1.begin(), v1.end(), v1.begin(), v1.end()) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_ALL_EQ(v1.begin(), v1.end(), v2.begin(), v2.end()) );
|
||||
|
||||
BOOST_TEST( BOOST_TEST_ALL_WITH(v1.begin(), v1.end(), v1.begin(), v1.end(), boost::detail::lw_test_eq()) );
|
||||
BOOST_TEST_NOT( BOOST_TEST_ALL_WITH(v1.begin(), v1.end(), v2.begin(), v2.end(), boost::detail::lw_test_eq()) );
|
||||
|
||||
int const * p = 0;
|
||||
|
||||
BOOST_TEST( p == 0 ) || BOOST_TEST_EQ( *p, 0 );
|
||||
BOOST_TEST( p != 0 ) && BOOST_TEST_EQ( *p, 0 );
|
||||
|
||||
int x = 0;
|
||||
p = &x;
|
||||
|
||||
BOOST_TEST( p == 0 ) || BOOST_TEST_EQ( *p, 0 );
|
||||
BOOST_TEST( p != 0 ) && BOOST_TEST_EQ( *p, 0 );
|
||||
|
||||
return boost::report_errors() == 14? 0: 1;
|
||||
}
|
||||
Reference in New Issue
Block a user