mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Fixed replace(inPlace) function
and added tests (should have done that in the first place - I'll never learn!)
This commit is contained in:
		| @@ -21,22 +21,14 @@ namespace Catch { | ||||
|         :   StreamingReporterBase( _config ) | ||||
|         {} | ||||
|          | ||||
|         static bool replace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { | ||||
|             std::size_t i = str.find( replaceThis ); | ||||
|             if( i != std::string::npos ) { | ||||
|                 str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); | ||||
|                 return true; | ||||
|             } | ||||
|             return false; | ||||
|         } | ||||
|         static std::string escape( std::string const& str ) { | ||||
|             std::string escaped = str; | ||||
|             while(  replace( escaped, "\'", "|\'" ) || | ||||
|                     replace( escaped, "\n", "|n" ) || | ||||
|                     replace( escaped, "\r", "|r" ) || | ||||
|                     replace( escaped, "|", "||" ) || | ||||
|                     replace( escaped, "[", "|[" ) || | ||||
|                     replace( escaped, "]", "|]" ) ); | ||||
|             replaceInPlace( escaped, "\'", "|\'" ); | ||||
|             replaceInPlace( escaped, "\n", "|n" ); | ||||
|             replaceInPlace( escaped, "\r", "|r" ); | ||||
|             replaceInPlace( escaped, "|", "||" ); | ||||
|             replaceInPlace( escaped, "[", "|[" ); | ||||
|             replaceInPlace( escaped, "]", "|]" ); | ||||
|             return escaped; | ||||
|         } | ||||
|         virtual ~TeamCityReporter(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash