Add source_location::to_string

This commit is contained in:
Peter Dimov
2021-09-19 00:45:15 +03:00
parent 6aabfebae6
commit b7a43990e6
2 changed files with 54 additions and 23 deletions
+11 -1
View File
@@ -8,6 +8,11 @@
int main()
{
{
boost::source_location loc;
BOOST_TEST_EQ( loc.to_string(), std::string( "(unknown source location)" ) );
}
{
boost::source_location loc;
@@ -17,13 +22,18 @@ int main()
BOOST_TEST_EQ( os.str(), std::string( "(unknown source location)" ) );
}
{
boost::source_location loc = BOOST_CURRENT_LOCATION;
BOOST_TEST_EQ( loc.to_string(), std::string( __FILE__ ) + ":26 in function '" + BOOST_CURRENT_FUNCTION + "'" );
}
{
boost::source_location loc = BOOST_CURRENT_LOCATION;
std::ostringstream os;
os << loc;
BOOST_TEST_EQ( os.str(), std::string( __FILE__ ) + ":21: in function '" + BOOST_CURRENT_FUNCTION + "'" );
BOOST_TEST_EQ( os.str(), std::string( __FILE__ ) + ":31 in function '" + BOOST_CURRENT_FUNCTION + "'" );
}
return boost::report_errors();