mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Session::applyCommandLine overload on wchar_t (#1401)
* Session::applyCommandLine overload on wchar_t This allows users on Windows to use Catch::Session::applyCommandLine with wchar_t * arguments of application. With this change Session::run became templated so both char and wchar_t version have the same implementation.
This commit is contained in:
		 JoeyGrajciar
					JoeyGrajciar
				
			
				
					committed by
					
						 Martin Hořeňovský
						Martin Hořeňovský
					
				
			
			
				
	
			
			
			 Martin Hořeňovský
						Martin Hořeňovský
					
				
			
						parent
						
							6b9ca0888a
						
					
				
				
					commit
					e1307016f0
				
			| @@ -185,22 +185,8 @@ namespace Catch { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     void Session::useConfigData( ConfigData const& configData ) { | ||||
|         m_configData = configData; | ||||
|         m_config.reset(); | ||||
|     } | ||||
|  | ||||
|     int Session::run( int argc, char* argv[] ) { | ||||
|         if( m_startupExceptions ) | ||||
|             return 1; | ||||
|         int returnCode = applyCommandLine( argc, argv ); | ||||
|         if( returnCode == 0 ) | ||||
|             returnCode = run(); | ||||
|         return returnCode; | ||||
|     } | ||||
|  | ||||
| #if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(UNICODE) | ||||
|     int Session::run( int argc, wchar_t* const argv[] ) { | ||||
|     int Session::applyCommandLine( int argc, wchar_t const * const * argv ) { | ||||
|  | ||||
|         char **utf8Argv = new char *[ argc ]; | ||||
|  | ||||
| @@ -212,7 +198,7 @@ namespace Catch { | ||||
|             WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL ); | ||||
|         } | ||||
|  | ||||
|         int returnCode = run( argc, utf8Argv ); | ||||
|         int returnCode = applyCommandLine( argc, utf8Argv ); | ||||
|  | ||||
|         for ( int i = 0; i < argc; ++i ) | ||||
|             delete [] utf8Argv[ i ]; | ||||
| @@ -222,6 +208,12 @@ namespace Catch { | ||||
|         return returnCode; | ||||
|     } | ||||
| #endif | ||||
|  | ||||
|     void Session::useConfigData( ConfigData const& configData ) { | ||||
|         m_configData = configData; | ||||
|         m_config.reset(); | ||||
|     } | ||||
|  | ||||
|     int Session::run() { | ||||
|         if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) { | ||||
|             Catch::cout() << "...waiting for enter/ return before starting" << std::endl; | ||||
|   | ||||
| @@ -26,13 +26,22 @@ namespace Catch { | ||||
|         void libIdentify(); | ||||
|  | ||||
|         int applyCommandLine( int argc, char const * const * argv ); | ||||
|     #if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(UNICODE) | ||||
|         int applyCommandLine( int argc, wchar_t const * const * argv ); | ||||
|     #endif | ||||
|  | ||||
|         void useConfigData( ConfigData const& configData ); | ||||
|  | ||||
|         int run( int argc, char* argv[] ); | ||||
|     #if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(UNICODE) | ||||
|         int run( int argc, wchar_t* const argv[] ); | ||||
|     #endif | ||||
|         template<typename CharT> | ||||
|         int run(int argc, CharT const * const argv[]) { | ||||
|             if (m_startupExceptions) | ||||
|                 return 1; | ||||
|             int returnCode = applyCommandLine(argc, argv); | ||||
|             if (returnCode == 0) | ||||
|                 returnCode = run(); | ||||
|             return returnCode; | ||||
|         } | ||||
|      | ||||
|         int run(); | ||||
|  | ||||
|         clara::Parser const& cli() const; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user