include/cppunit/Asserter.h | 28 ++++++++++++------------- src/cppunit/Asserter.cpp | 50 ++++++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 39 deletions(-)
New commits: commit d0bf35d30f0662189f646a5c67d89715b725f12c Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sat Jan 6 19:33:23 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sat Jan 6 20:35:02 2024 +0100 make these similar ones consistent Change-Id: If1da3c7c255d9db83e2dc6181d283b9d82c147bb Reviewed-on: https://gerrit.libreoffice.org/c/cppunit/+/161719 Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/include/cppunit/Asserter.h b/include/cppunit/Asserter.h index 2010739..15f5c21 100644 --- a/include/cppunit/Asserter.h +++ b/include/cppunit/Asserter.h @@ -53,7 +53,7 @@ struct Asserter /*! rief Throws a Exception with the specified message and location. * \deprecated Use fail( Message, SourceLine ) instead. */ - [[noreturn]] static void CPPUNIT_API fail( std::string message, + [[noreturn]] static void CPPUNIT_API fail( const std::string& message, const SourceLine &sourceLine = SourceLine() ); /*! rief Throws a Exception with the specified message and location. @@ -74,7 +74,7 @@ struct Asserter * \param sourceLine Location of the assertion. */ static void CPPUNIT_API failIf( bool shouldFail, - std::string message, + const std::string& message, const SourceLine &sourceLine = SourceLine() ); /*! rief Returns a expected value string for a message, case equal than @@ -173,11 +173,11 @@ struct Asserter * what are the differences between the expected and actual value. * \param shortDescription Short description for the failure message. */ - [[noreturn]] static void CPPUNIT_API failNotLess( std::string expected, - std::string actual, + [[noreturn]] static void CPPUNIT_API failNotLess( const std::string& expected, + const std::string& actual, const SourceLine &sourceLine, const AdditionalMessage &additionalMessage = AdditionalMessage(), - std::string shortDescription = "less assertion failed" ); + const std::string& shortDescription = "less assertion failed" ); /*! rief Throws an Exception with the specified message and location. * \param expected Text describing the expected value. @@ -187,11 +187,11 @@ struct Asserter * what are the differences between the expected and actual value. * \param shortDescription Short description for the failure message. */ - [[noreturn]] static void CPPUNIT_API failNotGreater( std::string expected, - std::string actual, + [[noreturn]] static void CPPUNIT_API failNotGreater( const std::string& expected, + const std::string& actual, const SourceLine &sourceLine, const AdditionalMessage &additionalMessage = AdditionalMessage(), - std::string shortDescription = "greater assertion failed" ); + const std::string& shortDescription = "greater assertion failed" ); /*! rief Throws an Exception with the specified message and location. * \param expected Text describing the expected value. @@ -201,11 +201,11 @@ struct Asserter * what are the differences between the expected and actual value. * \param shortDescription Short description for the failure message. */ - [[noreturn]] static void CPPUNIT_API failNotLessEqual( std::string expected, - std::string actual, + [[noreturn]] static void CPPUNIT_API failNotLessEqual( const std::string& expected, + const std::string& actual, const SourceLine &sourceLine, const AdditionalMessage &additionalMessage = AdditionalMessage(), - std::string shortDescription = "less equal assertion failed" ); + const std::string& shortDescription = "less equal assertion failed" ); /*! rief Throws an Exception with the specified message and location. * \param expected Text describing the expected value. @@ -215,11 +215,11 @@ struct Asserter * what are the differences between the expected and actual value. * \param shortDescription Short description for the failure message. */ - [[noreturn]] static void CPPUNIT_API failNotGreaterEqual( std::string expected, - std::string actual, + [[noreturn]] static void CPPUNIT_API failNotGreaterEqual( const std::string& expected, + const std::string& actual, const SourceLine &sourceLine, const AdditionalMessage &additionalMessage = AdditionalMessage(), - std::string shortDescription = "greater equal assertion failed" ); /*! rief Throws an Exception with the specified message and location. + const std::string& shortDescription = "greater equal assertion failed" ); /*! rief Throws an Exception with the specified message and location. * \param shouldFail if * nothing happen. diff --git a/src/cppunit/Asserter.cpp b/src/cppunit/Asserter.cpp index fe2097e..29588a6 100644 --- a/src/cppunit/Asserter.cpp +++ b/src/cppunit/Asserter.cpp @@ -8,7 +8,7 @@ CPPUNIT_NS_BEGIN // coverity[+kill] [[noreturn]] void -Asserter::fail( std::string message, +Asserter::fail( const std::string& message, const SourceLine &sourceLine ) { fail( Message( "assertion failed", message ), sourceLine ); @@ -24,8 +24,8 @@ Asserter::fail( const Message &message, void -Asserter::failIf( bool shouldFail, - const Message &message, +Asserter::failIf( bool shouldFail, + const Message &message, const SourceLine &sourceLine ) { if ( shouldFail ) @@ -34,8 +34,8 @@ Asserter::failIf( bool shouldFail, void -Asserter::failIf( bool shouldFail, - std::string message, +Asserter::failIf( bool shouldFail, + const std::string& message, const SourceLine &sourceLine ) { failIf( shouldFail, Message( "assertion failed", message ), sourceLine ); @@ -125,11 +125,11 @@ Asserter::failNotEqual( const std::string& expected, [[noreturn]] void -Asserter::failNotLess( std::string expected, - std::string actual, - const SourceLine &sourceLine, - const AdditionalMessage &additionalMessage, - std::string shortDescription ) +Asserter::failNotLess( const std::string& expected, + const std::string& actual, + const SourceLine &sourceLine, + const AdditionalMessage &additionalMessage, + const std::string& shortDescription ) { fail( makeMessage( makeExpectedLess(expected), makeActual(actual), @@ -140,11 +140,11 @@ Asserter::failNotLess( std::string expected, [[noreturn]] void -Asserter::failNotGreater( std::string expected, - std::string actual, - const SourceLine &sourceLine, - const AdditionalMessage &additionalMessage, - std::string shortDescription ) +Asserter::failNotGreater( const std::string& expected, + const std::string& actual, + const SourceLine &sourceLine, + const AdditionalMessage &additionalMessage, + const std::string& shortDescription ) { fail( makeMessage( makeExpectedGreater(expected), makeActual(actual), @@ -154,30 +154,30 @@ Asserter::failNotGreater( std::string expected, } [[noreturn]] void -Asserter::failNotLessEqual( std::string expected, - std::string actual, +Asserter::failNotLessEqual( const std::string& expected, + const std::string& actual, const SourceLine &sourceLine, const AdditionalMessage &additionalMessage, - std::string shortDescription ) + const std::string& shortDescription ) { fail( makeMessage( makeExpectedLessEqual(expected), makeActual(actual), shortDescription, - additionalMessage ), + additionalMessage ), sourceLine ); } [[noreturn]] void -Asserter::failNotGreaterEqual( std::string expected, - std::string actual, - const SourceLine &sourceLine, - const AdditionalMessage &additionalMessage, - std::string shortDescription ) +Asserter::failNotGreaterEqual( const std::string& expected, + const std::string& actual, + const SourceLine &sourceLine, + const AdditionalMessage &additionalMessage, + const std::string& shortDescription ) { fail( makeMessage( makeExpectedGreaterEqual(expected), makeActual(actual), shortDescription, - additionalMessage ), + additionalMessage ), sourceLine ); } void