mirror of
https://github.com/boostorg/test.git
synced 2026-02-28 05:32:42 +00:00
Merge branch 'develop' into tractickets/11054-multiprecision_test_fixes-doc
Conflicts: include/boost/test/tools/floating_point_comparison.hpp
This commit is contained in:
@@ -69,6 +69,8 @@
|
||||
# [ticket 6002] Failed to completely redirect TestLog to file (duplicates)
|
||||
# [ticket 6071] Boost Test (Boost 1.46.0) GCC 4.6.1 error: ambiguous overload for ‘operator[]’
|
||||
# [ticket 6074] warnings-as-errors not usable with Boost.test in release mode
|
||||
# [ticket 6161] SunOS: bad putenv declaration (duplicates #6766)
|
||||
# [ticket 6766] incorrect declaration for putenv in config.hpp
|
||||
# [ticket 6712] Eliminate warnings with GCC
|
||||
# [ticket 6748] Link in the documentation points to wrong page
|
||||
# [ticket 7046] Output full error message, not just 512 chars
|
||||
|
||||
@@ -152,6 +152,7 @@ make(DS const& ds)
|
||||
|
||||
|
||||
// fwrd declaration for singletons
|
||||
#if !(defined(BOOST_MSVC) && (BOOST_MSVC < 1600))
|
||||
//! @overload boost::unit_test::data::make()
|
||||
template<typename T>
|
||||
inline typename BOOST_TEST_ENABLE_IF<!is_forward_iterable<T>::value &&
|
||||
@@ -159,6 +160,7 @@ inline typename BOOST_TEST_ENABLE_IF<!is_forward_iterable<T>::value &&
|
||||
!boost::is_array< typename boost::remove_reference<T>::type >::value,
|
||||
monomorphic::singleton<T> >::type
|
||||
make( T const& v );
|
||||
#endif
|
||||
|
||||
|
||||
// fwrd declaration for collections
|
||||
|
||||
@@ -5,11 +5,8 @@
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile$
|
||||
//
|
||||
// Version : $Revision: 74248 $
|
||||
//
|
||||
// Description : bitwose comparison manipulator implementation
|
||||
//! @file
|
||||
//! Bitwise comparison manipulator implementation
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_TOOLS_DETAIL_BITWISE_MANIP_HPP_012705GER
|
||||
@@ -36,6 +33,7 @@ namespace test_tools {
|
||||
// ************** bitwise comparison manipulator ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
//! Bitwise comparison manipulator
|
||||
struct bitwise {};
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -47,6 +45,11 @@ operator<<( unit_test::lazy_ostream const&, bitwise ) { return 0; }
|
||||
|
||||
namespace tt_detail {
|
||||
|
||||
/*!@brief Bitwise comparison of two operands
|
||||
*
|
||||
* This class constructs an @ref assertion_result that contains precise bit comparison information.
|
||||
* In particular the location of the mismatches (if any) are printed in the assertion result.
|
||||
*/
|
||||
template<typename Lhs, typename Rhs, typename E>
|
||||
inline assertion_result
|
||||
bitwise_compare(Lhs const& lhs, Rhs const& rhs, E const& expr )
|
||||
@@ -88,6 +91,12 @@ bitwise_compare(Lhs const& lhs, Rhs const& rhs, E const& expr )
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
//! Returns an assertion_result using the bitwise comparison out of an expression
|
||||
//!
|
||||
//! This is used as a modifer of the normal operator<< on expressions to use the
|
||||
//! bitwise comparison.
|
||||
//!
|
||||
//! @note Available only for compilers supporting the @c auto declaration.
|
||||
template<typename T1, typename T2, typename T3, typename T4>
|
||||
inline assertion_result
|
||||
operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,assertion::op::EQ<T3,T4> > > const& ae, bitwise )
|
||||
|
||||
@@ -38,6 +38,9 @@ struct is_cstring_impl : public mpl::false_ {};
|
||||
template<typename T>
|
||||
struct is_cstring_impl<T const*> : public is_cstring_impl<T*> {};
|
||||
|
||||
template<typename T>
|
||||
struct is_cstring_impl<T const* const> : public is_cstring_impl<T*> {};
|
||||
|
||||
template<>
|
||||
struct is_cstring_impl<char*> : public mpl::true_ {};
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef __SUNPRO_CC
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
#ifndef BOOST_RT_PARAM_CUSTOM_STRING
|
||||
@@ -44,9 +48,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __SUNPRO_CC
|
||||
extern int putenv(char*);
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost {
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ rule test-btl-lib-c11 ( test-rule : test-name : lib-name ? : pattern_file * : so
|
||||
<toolset>gcc-4.5:<cxxflags>-std=c++0x
|
||||
<toolset>gcc-4.6:<cxxflags>-std=c++0x
|
||||
<toolset>gcc-4.7:<cxxflags>-std=c++11
|
||||
<toolset>gcc-4.8:<cxxflags>-std=c++11
|
||||
<toolset>gcc-4.9:<cxxflags>-std=c++11
|
||||
<toolset>borland:<cxxflags>-w-8080
|
||||
<toolset>borland:<cxxflags>-w-8084
|
||||
<toolset>msvc-6.5:<link>static
|
||||
@@ -116,6 +118,7 @@ test-suite "unit_test_framework_test"
|
||||
[ test-btl-lib run : single_header_test ]
|
||||
[ test-btl-lib run-fail : minimal_test ]
|
||||
[ test-btl-lib run : foreach_test ]
|
||||
[ test-btl-lib run : test_windows_headers : boost_unit_test_framework ]
|
||||
[ test-btl-lib run : output_test_stream_test : boost_unit_test_framework ]
|
||||
[ test-btl-lib run : result_report_test : boost_unit_test_framework : test_files/result_report_test.pattern ]
|
||||
[ test-btl-lib run : parameterized_test_test : boost_unit_test_framework ]
|
||||
|
||||
@@ -29,6 +29,12 @@ using utf::const_string;
|
||||
namespace std { using ::toupper; }
|
||||
# endif
|
||||
|
||||
#ifdef BOOST_NO_CXX11_DECLTYPE
|
||||
#define TEST_SURROUND_EXPRESSION(x) (x)
|
||||
#else
|
||||
#define TEST_SURROUND_EXPRESSION(x) x
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
bool predicate( char c1, char c2 ) { return (std::toupper)( c1 ) == (std::toupper)( c2 ); }
|
||||
@@ -40,17 +46,17 @@ BOOST_AUTO_TEST_CASE( test_mismatch )
|
||||
const_string cs1( "test_string" );
|
||||
const_string cs2( "test_stream" );
|
||||
|
||||
BOOST_TEST( utf::mismatch( cs1.begin(), cs1.end(), cs2.begin(), cs2.end() ).first - cs1.begin() == 8 );
|
||||
BOOST_TEST( TEST_SURROUND_EXPRESSION(utf::mismatch( cs1.begin(), cs1.end(), cs2.begin(), cs2.end() ).first - cs1.begin()) == 8 );
|
||||
|
||||
cs2 = "trest";
|
||||
BOOST_TEST( utf::mismatch( cs1.begin(), cs1.end(), cs2.begin(), cs2.end() ).first - cs1.begin() == 1 );
|
||||
BOOST_TEST( TEST_SURROUND_EXPRESSION(utf::mismatch( cs1.begin(), cs1.end(), cs2.begin(), cs2.end() ).first - cs1.begin()) == 1 );
|
||||
|
||||
cs2 = "test_string_klmn";
|
||||
BOOST_TEST( utf::mismatch( cs1.begin(), cs1.end(), cs2.begin(), cs2.end() ).first - cs1.begin() == 11 );
|
||||
BOOST_TEST( TEST_SURROUND_EXPRESSION(utf::mismatch( cs1.begin(), cs1.end(), cs2.begin(), cs2.end() ).first - cs1.begin()) == 11 );
|
||||
|
||||
cs2 = "TeSt_liNk";
|
||||
BOOST_TEST(
|
||||
utf::mismatch( cs1.begin(), cs1.end(), cs2.begin(), cs2.end(), std::ptr_fun( predicate ) ).first - cs1.begin() == 5 );
|
||||
TEST_SURROUND_EXPRESSION(utf::mismatch( cs1.begin(), cs1.end(), cs2.begin(), cs2.end(), std::ptr_fun( predicate ) ).first - cs1.begin()) == 5 );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -60,11 +66,11 @@ BOOST_AUTO_TEST_CASE( test_find_first_not_of )
|
||||
const_string cs( "test_string" );
|
||||
const_string another( "tes" );
|
||||
|
||||
BOOST_TEST( utf::find_first_not_of( cs.begin(), cs.end(), another.begin(), another.end() ) - cs.begin() == 4 );
|
||||
BOOST_TEST( TEST_SURROUND_EXPRESSION(utf::find_first_not_of( cs.begin(), cs.end(), another.begin(), another.end() ) - cs.begin()) == 4 );
|
||||
|
||||
another = "T_sE";
|
||||
BOOST_TEST(
|
||||
utf::find_first_not_of( cs.begin(), cs.end(), another.begin(), another.end(), std::ptr_fun( predicate ) ) - cs.begin() == 7 );
|
||||
TEST_SURROUND_EXPRESSION(utf::find_first_not_of( cs.begin(), cs.end(), another.begin(), another.end(), std::ptr_fun( predicate ) ) - cs.begin()) == 7 );
|
||||
|
||||
another = "tes_ring";
|
||||
BOOST_TEST( utf::find_last_not_of( cs.begin(), cs.end(), another.begin(), another.end() ) == cs.end() );
|
||||
@@ -77,16 +83,16 @@ BOOST_AUTO_TEST_CASE( test_find_last_of )
|
||||
const_string cs( "test_string" );
|
||||
const_string another( "tes" );
|
||||
|
||||
BOOST_TEST( utf::find_last_of( cs.begin(), cs.end(), another.begin(), another.end() ) - cs.begin() == 6 );
|
||||
BOOST_TEST( TEST_SURROUND_EXPRESSION(utf::find_last_of( cs.begin(), cs.end(), another.begin(), another.end() ) - cs.begin()) == 6 );
|
||||
|
||||
another = "_Se";
|
||||
BOOST_TEST( utf::find_last_of( cs.begin(), cs.end(), another.begin(), another.end(), std::ptr_fun( predicate ) ) - cs.begin() == 5 );
|
||||
BOOST_TEST( TEST_SURROUND_EXPRESSION(utf::find_last_of( cs.begin(), cs.end(), another.begin(), another.end(), std::ptr_fun( predicate ) ) - cs.begin()) == 5 );
|
||||
|
||||
another = "qw";
|
||||
BOOST_TEST( utf::find_last_of( cs.begin(), cs.end(), another.begin(), another.end() ) == cs.end() );
|
||||
|
||||
cs = "qerty";
|
||||
BOOST_TEST( utf::find_last_of( cs.begin(), cs.end(), another.begin(), another.end() ) - cs.begin() == 0 );
|
||||
BOOST_TEST( TEST_SURROUND_EXPRESSION(utf::find_last_of( cs.begin(), cs.end(), another.begin(), another.end() ) - cs.begin()) == 0 );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -96,10 +102,10 @@ BOOST_AUTO_TEST_CASE( test_find_last_not_of )
|
||||
const_string cs( "test_string" );
|
||||
const_string another( "string" );
|
||||
|
||||
BOOST_TEST( utf::find_last_not_of( cs.begin(), cs.end(), another.begin(), another.end() ) - cs.begin() == 4 );
|
||||
BOOST_TEST( TEST_SURROUND_EXPRESSION(utf::find_last_not_of( cs.begin(), cs.end(), another.begin(), another.end() ) - cs.begin()) == 4 );
|
||||
|
||||
another = "_SeG";
|
||||
BOOST_TEST( utf::find_last_not_of( cs.begin(), cs.end(), another.begin(), another.end(), std::ptr_fun( predicate ) ) - cs.begin() == 9 );
|
||||
BOOST_TEST( TEST_SURROUND_EXPRESSION(utf::find_last_not_of( cs.begin(), cs.end(), another.begin(), another.end(), std::ptr_fun( predicate ) ) - cs.begin()) == 9 );
|
||||
|
||||
another = "e_string";
|
||||
BOOST_TEST( utf::find_last_not_of( cs.begin(), cs.end(), another.begin(), another.end() ) == cs.end() );
|
||||
|
||||
@@ -133,8 +133,13 @@ BOOST_AUTO_TEST_CASE( test_readonly_property )
|
||||
|
||||
BOOST_TEST( p_b->foo() == 1 );
|
||||
|
||||
BOOST_TEST( (p_one ^ 3) == 2 );
|
||||
BOOST_TEST( p_two / 2 == 1 );
|
||||
BOOST_TEST( (p_one ^ 3) == 2 ); // ^ has lower precedence than ==
|
||||
#ifndef BOOST_NO_CXX11_DECLTYPE
|
||||
BOOST_TEST( p_two / 2 == 1 ); // / has higher precedence than ==
|
||||
#else
|
||||
BOOST_TEST( (p_two / 2) == 1 ); // / has higher precedence than ==
|
||||
// but the result of operator/ is not defined in this case
|
||||
#endif
|
||||
|
||||
BOOST_TEST( !p_b_ptr );
|
||||
|
||||
|
||||
@@ -721,8 +721,8 @@ TEST_CASE( test_BOOST_TEST_collection_comp )
|
||||
l.push_back( 3 );
|
||||
l.push_back( 2 );
|
||||
|
||||
BOOST_TEST_FWD_1( v <= l, "check v <= l has failed.\nMismatch at position 2: 3 > 2" );
|
||||
BOOST_TEST_FWD_1( v == l, "check v == l has failed.\nMismatch at position 1: 2 != 3\nMismatch at position 2: 3 != 2" );
|
||||
BOOST_TEST_FWD_1( v <= l, "check v <= l has failed. \nMismatch at position 2: 3 > 2" );
|
||||
BOOST_TEST_FWD_1( v == l, "check v == l has failed. \nMismatch at position 1: 2 != 3\nMismatch at position 2: 3 != 2" );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -752,15 +752,15 @@ TEST_CASE( test_BOOST_TEST_fpv_comp )
|
||||
BOOST_TEST( tt::fpc_tolerance<float>() == 0 );
|
||||
|
||||
BOOST_TEST( d1 > d2 );
|
||||
BOOST_TEST_FWD_3( d1+1./1e20 > d2, 1e-5% tt::tolerance(), "check d1+1./1e20 > d2 has failed [1e-005 + 1e-020 <= 1e-005]. Relative difference exceeds tolerance [0.000908265 > 1e-007]" );
|
||||
BOOST_TEST_FWD_3( d1+1./1e20 > d2, 1e-5% tt::tolerance(), "check d1+1./1e20 > d2 has failed [1e-05 + 1e-20 <= 1e-05]. Relative difference exceeds tolerance [0.000908265 > 1e-07]" );
|
||||
BOOST_TEST( tt::fpc_tolerance<double>() == 0 );
|
||||
BOOST_TEST( d2 <= d1, tt::tolerance( tt::fpc::percent_tolerance( 1e-5 ) ) );
|
||||
BOOST_TEST( tt::fpc_tolerance<double>() == 0 );
|
||||
|
||||
BOOST_TEST_FWD_3( d1-1e-5 == 0., tt::tolerance( 1e-7 ), "check d1-1e-5 == 0. has failed [1e-005 - 1e-005 != 0]. Absolute value exceeds tolerance [|1e-006| > 1e-007]" );
|
||||
BOOST_TEST_FWD_3( d1-1e-5 != 0., tt::tolerance( 1e-4 ), "check d1-1e-5 != 0. has failed [1e-005 - 1e-005 == 0]. Absolute value is within tolerance [|1e-006| < 0.0001]" );
|
||||
BOOST_TEST_FWD_3( 0. != 1e-5-d1, tt::tolerance( 1e-4 ), "check 0. != 1e-5-d1 has failed [0 == -1e-006]. Absolute value is within tolerance [|-1e-006| < 0.0001]" );
|
||||
BOOST_TEST_FWD_3( d2-1e-5 < 0., tt::tolerance( 1e-6 ), "check d2-1e-5 < 0. has failed [1e-005 - 1e-005 >= 0]. Absolute value exceeds tolerance [|1.01e-006| > 1e-006]" );
|
||||
BOOST_TEST_FWD_3( d1-1e-5 == 0., tt::tolerance( 1e-7 ), "check d1-1e-5 == 0. has failed [1e-05 - 1e-05 != 0]. Absolute value exceeds tolerance [|1e-06| > 1e-07]" );
|
||||
BOOST_TEST_FWD_3( d1-1e-5 != 0., tt::tolerance( 1e-4 ), "check d1-1e-5 != 0. has failed [1e-05 - 1e-05 == 0]. Absolute value is within tolerance [|1e-06| < 0.0001]" );
|
||||
BOOST_TEST_FWD_3( 0. != 1e-5-d1, tt::tolerance( 1e-4 ), "check 0. != 1e-5-d1 has failed [0 == -1e-06]. Absolute value is within tolerance [|-1e-06| < 0.0001]" );
|
||||
BOOST_TEST_FWD_3( d2-1e-5 < 0., tt::tolerance( 1e-6 ), "check d2-1e-5 < 0. has failed [1e-05 - 1e-05 >= 0]. Absolute value exceeds tolerance [|1.01e-06| > 1e-06]" );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -824,9 +824,9 @@ TEST_CASE( test_BOOST_TEST_bitwise )
|
||||
int a = 0xAB;
|
||||
int b = 0x88;
|
||||
short c = 0x8A;
|
||||
|
||||
BOOST_TEST( a == b, tt::bitwise() );
|
||||
BOOST_TEST( c == b, tt::bitwise() );
|
||||
// decltype is needed for this to work. Not the case for eg. MSVC 2008.
|
||||
BOOST_TEST_FWD_3( a == b, tt::bitwise(), "check a == b has failed [171 != 136]. Bitwise comparison failed\nMismatch at position 0\nMismatch at position 1\nMismatch at position 5" );
|
||||
BOOST_TEST_FWD_3( c == b, tt::bitwise(), "check c == b has failed [138 != 136]. Bitwise comparison failed\nMismatch at position 1\nOperands bit sizes mismatch: 16 != 32" );
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
32
test/test_windows_headers.cpp
Normal file
32
test/test_windows_headers.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// (C) Copyright Raffi Enficiaud 2015
|
||||
// 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.
|
||||
//
|
||||
// Tests some compilation troubleshooting issues with the windows headers (eg min/max macros)
|
||||
// ***************************************************************************
|
||||
|
||||
#define BOOST_TEST_MODULE test_windows_headers
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#ifdef BOOST_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp> // Extra test tool for FP comparison.
|
||||
|
||||
BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test, 2 )
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test )
|
||||
{
|
||||
// produces an error
|
||||
BOOST_TEST(1 == 0);
|
||||
|
||||
// this is added in order to compile floating point relative code as well
|
||||
// which might have trouble compiling if system headers are included (as for
|
||||
// boost.thread, eg. for std::min).
|
||||
BOOST_CHECK_CLOSE(1.1, 1.2, 1e-5);
|
||||
}
|
||||
Reference in New Issue
Block a user