mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
Removed redundant .c_str()s from StringRef usages
This commit is contained in:
parent
fa3535e95e
commit
ece64c3b3a
@ -79,7 +79,7 @@ namespace Catch {
|
||||
}
|
||||
void AssertionHandler::handle( ResultWas::OfType resultType, StringRef const& message ) {
|
||||
AssertionResultData data( resultType, LazyExpression( false ) );
|
||||
data.message = message.c_str();
|
||||
data.message = message;
|
||||
handle( data, nullptr );
|
||||
}
|
||||
void AssertionHandler::handle( ResultWas::OfType resultType, ITransientExpression const* expr, bool negated ) {
|
||||
@ -126,7 +126,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void AssertionHandler::useActiveException() {
|
||||
handle( ResultWas::ThrewException, Catch::translateActiveException().c_str() );
|
||||
handle( ResultWas::ThrewException, Catch::translateActiveException() );
|
||||
}
|
||||
|
||||
void AssertionHandler::setExceptionGuard() {
|
||||
|
@ -52,16 +52,23 @@ namespace Catch {
|
||||
|
||||
std::string AssertionResult::getExpression() const {
|
||||
if (isFalseTest(m_info.resultDisposition))
|
||||
return '!' + std::string(m_info.capturedExpression.c_str());
|
||||
return '!' + std::string(m_info.capturedExpression);
|
||||
else
|
||||
return std::string(m_info.capturedExpression.c_str());
|
||||
return m_info.capturedExpression;
|
||||
}
|
||||
|
||||
std::string AssertionResult::getExpressionInMacro() const {
|
||||
std::string expr;
|
||||
if( m_info.macroName[0] == 0 )
|
||||
return std::string(m_info.capturedExpression.c_str());
|
||||
else
|
||||
return std::string(m_info.macroName.c_str()) + "( " + m_info.capturedExpression.c_str() + " )";
|
||||
expr = m_info.capturedExpression;
|
||||
else {
|
||||
expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 );
|
||||
expr += m_info.macroName;
|
||||
expr += "( ";
|
||||
expr += m_info.capturedExpression;
|
||||
expr += " )";
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
||||
bool AssertionResult::hasExpandedExpression() const {
|
||||
@ -83,7 +90,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
std::string AssertionResult::getTestMacroName() const {
|
||||
return m_info.macroName.c_str();
|
||||
return m_info.macroName;
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@ -28,7 +28,7 @@ namespace Catch {
|
||||
public:
|
||||
// Keep most of this inline as it's on the code path that is being timed
|
||||
BenchmarkLooper( StringRef name )
|
||||
: m_name( name.c_str() ),
|
||||
: m_name( name ),
|
||||
m_resolution( getResolution() )
|
||||
{
|
||||
reportStart();
|
||||
|
@ -126,7 +126,7 @@
|
||||
#define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \
|
||||
do { \
|
||||
Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \
|
||||
catchAssertionHandler.handle( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str().c_str() ); \
|
||||
catchAssertionHandler.handle( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \
|
||||
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||
} while( Catch::alwaysFalse() )
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace Catch {
|
||||
auto matcherAsString = m_matcher.toString();
|
||||
os << Catch::Detail::stringify( m_arg ) << ' ';
|
||||
if( matcherAsString == Detail::unprintableString )
|
||||
os << m_matcherString.c_str();
|
||||
os << m_matcherString;
|
||||
else
|
||||
os << matcherAsString;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace Catch {
|
||||
BinaryExpr( bool comparisionResult, LhsT lhs, StringRef op, RhsT rhs )
|
||||
: m_result( comparisionResult ),
|
||||
m_lhs( lhs ),
|
||||
m_op( op.c_str() ),
|
||||
m_op( op ),
|
||||
m_rhs( rhs )
|
||||
{}
|
||||
};
|
||||
|
@ -42,7 +42,7 @@ namespace Catch {
|
||||
if( assertionResult.hasMessage() ) {
|
||||
// Copy message into messages list.
|
||||
// !TBD This should have been done earlier, somewhere
|
||||
MessageBuilder builder( assertionResult.getTestMacroName().c_str(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
|
||||
MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );
|
||||
builder << assertionResult.getMessage();
|
||||
builder.m_info.message = builder.m_stream.str();
|
||||
|
||||
|
@ -23,9 +23,9 @@ namespace Catch {
|
||||
.registerTest(
|
||||
makeTestCase(
|
||||
invoker,
|
||||
extractClassName( classOrMethod.c_str() ),
|
||||
nameAndTags.name.c_str(),
|
||||
nameAndTags.tags.c_str(),
|
||||
extractClassName( classOrMethod ),
|
||||
nameAndTags.name,
|
||||
nameAndTags.tags,
|
||||
lineInfo));
|
||||
} catch (...) {
|
||||
// Do not throw when constructing global objects, instead register the exception to be processed later
|
||||
|
@ -85,7 +85,7 @@ namespace {
|
||||
friend TablePrinter& operator << ( TablePrinter& tp, ColumnBreak ) {
|
||||
auto colStr = tp.m_oss.str();
|
||||
// This takes account of utf8 encodings
|
||||
auto strSize = Catch::StringRef( colStr.c_str(), colStr.size() ).numberOfCharacters();
|
||||
auto strSize = Catch::StringRef( colStr ).numberOfCharacters();
|
||||
tp.m_oss.str("");
|
||||
tp.open();
|
||||
if( tp.m_currentColumn == static_cast<int>(tp.m_columnInfos.size()-1) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user