mirror of
https://github.com/boostorg/assert.git
synced 2025-07-29 20:07:18 +02:00
Update source_location_test4.cpp
This commit is contained in:
@ -5,6 +5,21 @@
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstring>
|
||||
|
||||
static char const* adjust_filename( char const* file )
|
||||
{
|
||||
#if defined(__INTEL_LLVM_COMPILER) && __INTEL_LLVM_COMPILER >= 20210300
|
||||
|
||||
char const* fn = std::strrchr( file, '/' );
|
||||
return fn? fn + 1: file;
|
||||
|
||||
#else
|
||||
|
||||
return file;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
boost::source_location s_loc = BOOST_CURRENT_LOCATION;
|
||||
|
||||
@ -18,8 +33,8 @@ boost::source_location f( boost::source_location const& loc = BOOST_CURRENT_LOCA
|
||||
int main()
|
||||
{
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( s_loc.file_name(), __FILE__ );
|
||||
BOOST_TEST_EQ( s_loc.line(), 9 );
|
||||
BOOST_TEST_CSTR_EQ( s_loc.file_name(), adjust_filename(__FILE__) );
|
||||
BOOST_TEST_EQ( s_loc.line(), 24 );
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC < 90000
|
||||
// '__static_initialization_and_destruction_0'
|
||||
@ -29,15 +44,15 @@ int main()
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( c_loc.file_name(), __FILE__ );
|
||||
BOOST_TEST_EQ( c_loc.line(), 11 );
|
||||
BOOST_TEST_CSTR_EQ( c_loc.file_name(), adjust_filename(__FILE__) );
|
||||
BOOST_TEST_EQ( c_loc.line(), 26 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::source_location loc = f();
|
||||
|
||||
BOOST_TEST_CSTR_EQ( loc.file_name(), __FILE__ );
|
||||
BOOST_TEST( loc.line() == 13 || loc.line() == 37 );
|
||||
BOOST_TEST_CSTR_EQ( loc.file_name(), adjust_filename(__FILE__) );
|
||||
BOOST_TEST( loc.line() == 28 || loc.line() == 52 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
Reference in New Issue
Block a user