mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-03 21:49:32 +01:00 
			
		
		
		
	Lift toLower(char) to header
This commit is contained in:
		@@ -16,12 +16,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Catch {
 | 
					namespace Catch {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    namespace {
 | 
					 | 
				
			||||||
        char toLowerCh(char c) {
 | 
					 | 
				
			||||||
            return static_cast<char>( std::tolower( static_cast<unsigned char>(c) ) );
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    bool startsWith( std::string const& s, std::string const& prefix ) {
 | 
					    bool startsWith( std::string const& s, std::string const& prefix ) {
 | 
				
			||||||
        return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());
 | 
					        return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -38,13 +32,19 @@ namespace Catch {
 | 
				
			|||||||
        return s.find( infix ) != std::string::npos;
 | 
					        return s.find( infix ) != std::string::npos;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    void toLowerInPlace( std::string& s ) {
 | 
					    void toLowerInPlace( std::string& s ) {
 | 
				
			||||||
        std::transform( s.begin(), s.end(), s.begin(), toLowerCh );
 | 
					        std::transform( s.begin(), s.end(), s.begin(), []( char c ) {
 | 
				
			||||||
 | 
					            return toLower( c );
 | 
				
			||||||
 | 
					        } );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    std::string toLower( std::string const& s ) {
 | 
					    std::string toLower( std::string const& s ) {
 | 
				
			||||||
        std::string lc = s;
 | 
					        std::string lc = s;
 | 
				
			||||||
        toLowerInPlace( lc );
 | 
					        toLowerInPlace( lc );
 | 
				
			||||||
        return lc;
 | 
					        return lc;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    char toLower(char c) {
 | 
				
			||||||
 | 
					        return static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::string trim( std::string const& str ) {
 | 
					    std::string trim( std::string const& str ) {
 | 
				
			||||||
        static char const* whitespaceChars = "\n\r\t ";
 | 
					        static char const* whitespaceChars = "\n\r\t ";
 | 
				
			||||||
        std::string::size_type start = str.find_first_not_of( whitespaceChars );
 | 
					        std::string::size_type start = str.find_first_not_of( whitespaceChars );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,7 @@ namespace Catch {
 | 
				
			|||||||
    bool contains( std::string const& s, std::string const& infix );
 | 
					    bool contains( std::string const& s, std::string const& infix );
 | 
				
			||||||
    void toLowerInPlace( std::string& s );
 | 
					    void toLowerInPlace( std::string& s );
 | 
				
			||||||
    std::string toLower( std::string const& s );
 | 
					    std::string toLower( std::string const& s );
 | 
				
			||||||
 | 
					    char toLower( char c );
 | 
				
			||||||
    //! Returns a new string without whitespace at the start/end
 | 
					    //! Returns a new string without whitespace at the start/end
 | 
				
			||||||
    std::string trim( std::string const& str );
 | 
					    std::string trim( std::string const& str );
 | 
				
			||||||
    //! Returns a substring of the original ref without whitespace. Beware lifetimes!
 | 
					    //! Returns a substring of the original ref without whitespace. Beware lifetimes!
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user