mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-04 05:59:32 +01:00 
			
		
		
		
	Added clean-up
Clean-up statics at the end of main to avoid added noise when looking for leaks
This commit is contained in:
		@@ -24,14 +24,14 @@ int main (int argc, char * const argv[])
 | 
			
		||||
    int result = Catch::Main( argc, (char* const*)argv );
 | 
			
		||||
    
 | 
			
		||||
    [pool drain];
 | 
			
		||||
    return result;
 | 
			
		||||
    
 | 
			
		||||
#else
 | 
			
		||||
    
 | 
			
		||||
    return Catch::Main( argc, argv );
 | 
			
		||||
    int result =Catch::Main( argc, argv );
 | 
			
		||||
    
 | 
			
		||||
#endif
 | 
			
		||||
    Catch::Hub::cleanUp();
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif // TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED
 | 
			
		||||
 
 | 
			
		||||
@@ -77,7 +77,13 @@ namespace Catch
 | 
			
		||||
        static bool advanceGeneratorsForCurrentTest
 | 
			
		||||
            ();
 | 
			
		||||
        
 | 
			
		||||
        static void cleanUp
 | 
			
		||||
            ();
 | 
			
		||||
        
 | 
			
		||||
    private:
 | 
			
		||||
 | 
			
		||||
        static Hub*& singleInstance();
 | 
			
		||||
        
 | 
			
		||||
        GeneratorsForTest* findGeneratorsForCurrentTest
 | 
			
		||||
            ();
 | 
			
		||||
        
 | 
			
		||||
 
 | 
			
		||||
@@ -32,8 +32,27 @@ namespace Catch
 | 
			
		||||
    Hub& Hub::me
 | 
			
		||||
    ()
 | 
			
		||||
    {
 | 
			
		||||
        static Hub hub;
 | 
			
		||||
        Hub*& hub = singleInstance();
 | 
			
		||||
        if( !hub )
 | 
			
		||||
            hub = new Hub();
 | 
			
		||||
        return *hub;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    void Hub::cleanUp
 | 
			
		||||
    ()
 | 
			
		||||
    {
 | 
			
		||||
        Hub*& hub = singleInstance();
 | 
			
		||||
        delete hub;
 | 
			
		||||
        hub = NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    Hub*& Hub::singleInstance()
 | 
			
		||||
    {
 | 
			
		||||
        static Hub* hub = NULL;        
 | 
			
		||||
        return hub;
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 
 | 
			
		||||
@@ -370,7 +370,13 @@ namespace Catch
 | 
			
		||||
        static bool advanceGeneratorsForCurrentTest
 | 
			
		||||
            ();
 | 
			
		||||
 | 
			
		||||
        static void cleanUp
 | 
			
		||||
            ();
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
 | 
			
		||||
        static Hub*& singleInstance();
 | 
			
		||||
 | 
			
		||||
        GeneratorsForTest* findGeneratorsForCurrentTest
 | 
			
		||||
            ();
 | 
			
		||||
 | 
			
		||||
@@ -4513,8 +4519,27 @@ namespace Catch
 | 
			
		||||
    Hub& Hub::me
 | 
			
		||||
    ()
 | 
			
		||||
    {
 | 
			
		||||
        static Hub hub;
 | 
			
		||||
        Hub*& hub = singleInstance();
 | 
			
		||||
        if( !hub )
 | 
			
		||||
            hub = new Hub();
 | 
			
		||||
        return *hub;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    void Hub::cleanUp
 | 
			
		||||
    ()
 | 
			
		||||
    {
 | 
			
		||||
        Hub*& hub = singleInstance();
 | 
			
		||||
        delete hub;
 | 
			
		||||
        hub = NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
    Hub*& Hub::singleInstance()
 | 
			
		||||
    {
 | 
			
		||||
        static Hub* hub = NULL;
 | 
			
		||||
        return hub;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
@@ -6276,16 +6301,16 @@ int main (int argc, char * const argv[])
 | 
			
		||||
    int result = Catch::Main( argc, (char* const*)argv );
 | 
			
		||||
 | 
			
		||||
    [pool drain];
 | 
			
		||||
    return result;
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
    return Catch::Main( argc, argv );
 | 
			
		||||
    int result =Catch::Main( argc, argv );
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
    Catch::Hub::cleanUp();
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
//////
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user