mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Refactor some common code, use __LINE__ instead of __COUNTER__ where possible
This commit is contained in:
		| @@ -24,14 +24,12 @@ | |||||||
|  |  | ||||||
| namespace CatchOverrides { | namespace CatchOverrides { | ||||||
|  |  | ||||||
|     class ConfigGuard |     class ConfigGuard { | ||||||
|     { |  | ||||||
|     public: |     public: | ||||||
|         ConfigGuard() |         ConfigGuard() | ||||||
|             : origConfig(Catch::getCurrentContext().getConfig()) |             : origConfig(Catch::getCurrentContext().getConfig()) | ||||||
|         {} |         {} | ||||||
|         ~ConfigGuard() |         ~ConfigGuard() { | ||||||
|         { |  | ||||||
|             Catch::getCurrentMutableContext().setConfig(origConfig); |             Catch::getCurrentMutableContext().setConfig(origConfig); | ||||||
|         } |         } | ||||||
|         const Catch::Ptr<Catch::IConfig const>& value() const {return origConfig;} |         const Catch::Ptr<Catch::IConfig const>& value() const {return origConfig;} | ||||||
| @@ -45,133 +43,20 @@ namespace CatchOverrides { | |||||||
|     enum OverrideType { OverrideUpdate, OverrideReset}; // Note: ordered; update must be before reset |     enum OverrideType { OverrideUpdate, OverrideReset}; // Note: ordered; update must be before reset | ||||||
|  |  | ||||||
|     template <typename T> |     template <typename T> | ||||||
|     class Config |     class ConfigLineData { | ||||||
|     { |         typedef std::map<std::pair<int,OverrideType>, T> LineData; | ||||||
|         typedef std::map<std::pair<int,OverrideType>, bool> BoolLineData; |  | ||||||
|         typedef std::map<std::string, BoolLineData> FileBoolLineData; |  | ||||||
|         typedef std::map<std::pair<int,OverrideType>, int> LineData; |  | ||||||
|         typedef std::map<std::string, LineData> FileLineData; |         typedef std::map<std::string, LineData> FileLineData; | ||||||
|         typedef std::multimap<std::pair<int,OverrideType>, std::string> StringLineData; |  | ||||||
|         typedef std::map<std::string, StringLineData> FileStringLineData; |  | ||||||
|     public: |     public: | ||||||
|         bool includeSuccessfulResults(const std::string& file, int c) const |         T getValueForFileLine(const std::string& file, int line) const { | ||||||
|         { |             T result(false); | ||||||
|             bool result(false); |             FileLineData::const_iterator it = m_data.find(file); | ||||||
|             FileBoolLineData::const_iterator it = showSuccessfulTestsData.find(file); |             if( it != m_data.end() ) { | ||||||
|             if( it != showSuccessfulTestsData.end() ) |  | ||||||
|             { |  | ||||||
|                 BoolLineData::const_iterator start = it->second.begin(); |  | ||||||
|                 BoolLineData::const_iterator end = it->second.end(); |  | ||||||
|                 for( BoolLineData::const_iterator lineIt = it->second.begin(); lineIt != it->second.end(); ++lineIt ) { |  | ||||||
|                     const std::pair<int,OverrideType>& current = lineIt->first; |  | ||||||
|                     if( current.second == OverrideReset ) { |  | ||||||
|                         if( c == current.first ) { |  | ||||||
|                             result = lineIt->second; |  | ||||||
|                             end = lineIt; |  | ||||||
|                             break; |  | ||||||
|                         } |  | ||||||
|                         else |  | ||||||
|                             start = lineIt; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|                 for( BoolLineData::const_iterator lineIt = start; lineIt != end; ++lineIt ) { |  | ||||||
|                     const std::pair<int,OverrideType>& current = lineIt->first; |  | ||||||
|                     if( current.second == OverrideUpdate ) { |  | ||||||
|                         if( c < current.first ) |  | ||||||
|                             break; |  | ||||||
|                         result = lineIt->second; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             return result; |  | ||||||
|         } |  | ||||||
|         void insertSuccessfulResults(const std::string& file, OverrideType overRide, int c, bool v) |  | ||||||
|         { |  | ||||||
|             FileBoolLineData::iterator it = showSuccessfulTestsData.find(file); |  | ||||||
|             if( it == showSuccessfulTestsData.end() ) |  | ||||||
|             { |  | ||||||
|                 BoolLineData tmp; |  | ||||||
|                 std::pair<int,OverrideType> current = std::make_pair(c, overRide); |  | ||||||
|                 tmp.insert(std::make_pair(current,v)); |  | ||||||
|                 showSuccessfulTestsData.insert(std::make_pair(file, tmp)); |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 std::pair<int,OverrideType> current = std::make_pair(c, overRide); |  | ||||||
|                 BoolLineData::iterator lineIt = it->second.find(current); |  | ||||||
|                 if( lineIt == it->second.end() ) { |  | ||||||
|                     it->second.insert(std::make_pair(current,v)); |  | ||||||
|                 } |  | ||||||
|                 else { |  | ||||||
|                     lineIt->second = v; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         bool warnAboutMissingAssertions(const std::string& file, int c) const |  | ||||||
|         { |  | ||||||
|             bool result(false); |  | ||||||
|             FileBoolLineData::const_iterator it = missingAssertionData.find(file); |  | ||||||
|             if( it != missingAssertionData.end() ) |  | ||||||
|             { |  | ||||||
|                 BoolLineData::const_iterator start = it->second.begin(); |  | ||||||
|                 BoolLineData::const_iterator end = it->second.end(); |  | ||||||
|                 for( BoolLineData::const_iterator lineIt = it->second.begin(); lineIt != it->second.end(); ++lineIt ) { |  | ||||||
|                     const std::pair<int,OverrideType>& current = lineIt->first; |  | ||||||
|                     if( current.second == OverrideReset ) { |  | ||||||
|                         if( c == current.first ) { |  | ||||||
|                             result = lineIt->second; |  | ||||||
|                             end = lineIt; |  | ||||||
|                             break; |  | ||||||
|                         } |  | ||||||
|                         else |  | ||||||
|                             start = lineIt; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|                 for( BoolLineData::const_iterator lineIt = start; lineIt != end; ++lineIt ) { |  | ||||||
|                     const std::pair<int,OverrideType>& current = lineIt->first; |  | ||||||
|                     if( current.second == OverrideUpdate ) { |  | ||||||
|                         if( c < current.first ) |  | ||||||
|                             break; |  | ||||||
|                         result = lineIt->second; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             return result; |  | ||||||
|         } |  | ||||||
|         void insertMissingAssertions(const std::string& file, OverrideType overRide, int c, bool v) |  | ||||||
|         { |  | ||||||
|             FileBoolLineData::iterator it = missingAssertionData.find(file); |  | ||||||
|             if( it == missingAssertionData.end() ) |  | ||||||
|             { |  | ||||||
|                 BoolLineData tmp; |  | ||||||
|                 std::pair<int,OverrideType> current = std::make_pair(c, overRide); |  | ||||||
|                 tmp.insert(std::make_pair(current,v)); |  | ||||||
|                 missingAssertionData.insert(std::make_pair(file, tmp)); |  | ||||||
|             } |  | ||||||
|             else |  | ||||||
|             { |  | ||||||
|                 std::pair<int,OverrideType> current = std::make_pair(c, overRide); |  | ||||||
|                 BoolLineData::iterator lineIt = it->second.find(current); |  | ||||||
|                 if( lineIt == it->second.end() ) { |  | ||||||
|                     it->second.insert(std::make_pair(current,v)); |  | ||||||
|                 } |  | ||||||
|                 else { |  | ||||||
|                     lineIt->second = v; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         int abortAfter(const std::string& file, int c) const |  | ||||||
|         { |  | ||||||
|             int result(-1); |  | ||||||
|             FileLineData::const_iterator it = abortAfterData.find(file); |  | ||||||
|             if( it != abortAfterData.end() ) |  | ||||||
|             { |  | ||||||
|                 LineData::const_iterator start = it->second.begin(); |                 LineData::const_iterator start = it->second.begin(); | ||||||
|                 LineData::const_iterator end = it->second.end(); |                 LineData::const_iterator end = it->second.end(); | ||||||
|                 for( LineData::const_iterator lineIt = it->second.begin(); lineIt != it->second.end(); ++lineIt ) { |                 for( LineData::const_iterator lineIt = it->second.begin(); lineIt != it->second.end(); ++lineIt ) { | ||||||
|                     const std::pair<int,OverrideType>& current = lineIt->first; |                     const std::pair<int,OverrideType>& current = lineIt->first; | ||||||
|                     if( current.second == OverrideReset ) { |                     if( current.second == OverrideReset ) { | ||||||
|                         if( c == current.first ) { |                         if( line == current.first ) { | ||||||
|                             result = lineIt->second; |                             result = lineIt->second; | ||||||
|                             end = lineIt; |                             end = lineIt; | ||||||
|                             break; |                             break; | ||||||
| @@ -183,7 +68,7 @@ namespace CatchOverrides { | |||||||
|                 for( LineData::const_iterator lineIt = start; lineIt != end; ++lineIt ) { |                 for( LineData::const_iterator lineIt = start; lineIt != end; ++lineIt ) { | ||||||
|                     const std::pair<int,OverrideType>& current = lineIt->first; |                     const std::pair<int,OverrideType>& current = lineIt->first; | ||||||
|                     if( current.second == OverrideUpdate ) { |                     if( current.second == OverrideUpdate ) { | ||||||
|                         if( c < current.first ) |                         if( line < current.first ) | ||||||
|                             break; |                             break; | ||||||
|                         result = lineIt->second; |                         result = lineIt->second; | ||||||
|                     } |                     } | ||||||
| @@ -191,16 +76,17 @@ namespace CatchOverrides { | |||||||
|             } |             } | ||||||
|             return result; |             return result; | ||||||
|         } |         } | ||||||
|         void insertAbortAfter(const std::string& file, OverrideType overRide, int c, int v) { |         void recordValueForFileLine(const std::string& file, OverrideType overRide, int line, const T& v) | ||||||
|             FileLineData::iterator it = abortAfterData.find(file); |         { | ||||||
|             if( it == abortAfterData.end() ) { |             FileLineData::iterator it = m_data.find(file); | ||||||
|  |             if( it == m_data.end() ) { | ||||||
|                 LineData tmp; |                 LineData tmp; | ||||||
|                 std::pair<int,OverrideType> current = std::make_pair(c, overRide); |                 std::pair<int,OverrideType> current = std::make_pair(line, overRide); | ||||||
|                 tmp.insert(std::make_pair(current,v)); |                 tmp.insert(std::make_pair(current,v)); | ||||||
|                 abortAfterData.insert(std::make_pair(file, tmp)); |                 m_data.insert(std::make_pair(file, tmp)); | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 std::pair<int,OverrideType> current = std::make_pair(c, overRide); |                 std::pair<int,OverrideType> current = std::make_pair(line, overRide); | ||||||
|                 LineData::iterator lineIt = it->second.find(current); |                 LineData::iterator lineIt = it->second.find(current); | ||||||
|                 if( lineIt == it->second.end() ) { |                 if( lineIt == it->second.end() ) { | ||||||
|                     it->second.insert(std::make_pair(current,v)); |                     it->second.insert(std::make_pair(current,v)); | ||||||
| @@ -210,6 +96,37 @@ namespace CatchOverrides { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |     private: | ||||||
|  |         FileLineData m_data; | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     template <typename T> | ||||||
|  |     class Config { | ||||||
|  |         typedef std::map<std::pair<int,OverrideType>, bool> BoolLineData; | ||||||
|  |         typedef std::map<std::string, BoolLineData> FileBoolLineData; | ||||||
|  |         typedef std::map<std::pair<int,OverrideType>, int> LineData; | ||||||
|  |         typedef std::map<std::string, LineData> FileLineData; | ||||||
|  |         typedef std::multimap<std::pair<int,OverrideType>, std::string> StringLineData; | ||||||
|  |         typedef std::map<std::string, StringLineData> FileStringLineData; | ||||||
|  |     public: | ||||||
|  |         bool includeSuccessfulResults(const std::string& file, int line) const { | ||||||
|  |             return showSuccessfulTestsData.getValueForFileLine(file,line); | ||||||
|  |         } | ||||||
|  |         void insertSuccessfulResults(const std::string& file, OverrideType overRide, int line, bool v) { | ||||||
|  |             showSuccessfulTestsData.recordValueForFileLine(file, overRide, line, v); | ||||||
|  |         } | ||||||
|  |         bool warnAboutMissingAssertions(const std::string& file, int line) const { | ||||||
|  |             return missingAssertionData.getValueForFileLine(file,line); | ||||||
|  |         } | ||||||
|  |         void insertMissingAssertions(const std::string& file, OverrideType overRide, int line, bool v) { | ||||||
|  |             missingAssertionData.recordValueForFileLine(file, overRide, line, v); | ||||||
|  |         } | ||||||
|  |         int abortAfter(const std::string& file, int line) const { | ||||||
|  |             return abortAfterData.getValueForFileLine(file,line); | ||||||
|  |         } | ||||||
|  |         void insertAbortAfter(const std::string& file, OverrideType overRide, int line, int v) { | ||||||
|  |             abortAfterData.recordValueForFileLine(file, overRide, line, v); | ||||||
|  |         } | ||||||
|         std::vector<std::string> listOfTests(const std::string& file, int c) const { |         std::vector<std::string> listOfTests(const std::string& file, int c) const { | ||||||
|             std::vector<std::string> result; |             std::vector<std::string> result; | ||||||
|             FileStringLineData::const_iterator it = testData.find(file); |             FileStringLineData::const_iterator it = testData.find(file); | ||||||
| @@ -258,9 +175,9 @@ namespace CatchOverrides { | |||||||
|             return *s_instance; |             return *s_instance; | ||||||
|         } |         } | ||||||
|     private: |     private: | ||||||
|         FileBoolLineData showSuccessfulTestsData; |         ConfigLineData<bool> showSuccessfulTestsData; | ||||||
|         FileBoolLineData missingAssertionData; |         ConfigLineData<bool> missingAssertionData; | ||||||
|         FileLineData abortAfterData; |         ConfigLineData<int> abortAfterData; | ||||||
|         FileStringLineData testData; |         FileStringLineData testData; | ||||||
|          |          | ||||||
|         static Config<T>* s_instance; |         static Config<T>* s_instance; | ||||||
|   | |||||||
| @@ -251,16 +251,16 @@ private: | |||||||
| #define INTERNAL_CATCH_CONCAT_LINE_COUNTER( count ) INTERNAL_CATCH_UNIQUE_NAME_LINE( INTERNAL_CATCH_UNIQUE_NAME_LINE( __LINE__, _ ), count ) | #define INTERNAL_CATCH_CONCAT_LINE_COUNTER( count ) INTERNAL_CATCH_UNIQUE_NAME_LINE( INTERNAL_CATCH_UNIQUE_NAME_LINE( __LINE__, _ ), count ) | ||||||
|  |  | ||||||
| #define CATCH_INTERNAL_CONFIG_SHOW_SUCCESS2( v, Count ) \ | #define CATCH_INTERNAL_CONFIG_SHOW_SUCCESS2( v, Count ) \ | ||||||
|     namespace { CatchOverrides::ConfigShowSuccessfulTests<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H_____O_V_E_R_R_I_D_E____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, Count, v); } |     namespace { CatchOverrides::ConfigShowSuccessfulTests<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H_____O_V_E_R_R_I_D_E____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, __LINE__, v); } | ||||||
|  |  | ||||||
| #define CATCH_INTERNAL_CONFIG_WARN_MISSING_ASSERTIONS2( v, Count ) \ | #define CATCH_INTERNAL_CONFIG_WARN_MISSING_ASSERTIONS2( v, Count ) \ | ||||||
|     namespace { CatchOverrides::ConfigWarnMissingAssertions<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H_____O_V_E_R_R_I_D_E____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, Count, v); } |     namespace { CatchOverrides::ConfigWarnMissingAssertions<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H_____O_V_E_R_R_I_D_E____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, __LINE__, v); } | ||||||
|  |  | ||||||
| #define CATCH_INTERNAL_CONFIG_ABORT_AFTER2( v, Count ) \ | #define CATCH_INTERNAL_CONFIG_ABORT_AFTER2( v, Count ) \ | ||||||
|     namespace { CatchOverrides::ConfigAbortAfter<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H_____O_V_E_R_R_I_D_E____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, Count, v); } |     namespace { CatchOverrides::ConfigAbortAfter<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H_____O_V_E_R_R_I_D_E____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, __LINE__, v); } | ||||||
|  |  | ||||||
| #define CATCH_INTERNAL_CONFIG_ADD_TEST2( v, Count ) \ | #define CATCH_INTERNAL_CONFIG_ADD_TEST2( v, Count ) \ | ||||||
|     namespace { CatchOverrides::ConfigAddTest<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H_____O_V_E_R_R_I_D_E____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, Count, v); } |     namespace { CatchOverrides::ConfigAddTest<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H_____O_V_E_R_R_I_D_E____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, __LINE__, v); } | ||||||
|  |  | ||||||
| #define CATCH_INTERNAL_CONFIG_SHOW_SUCCESS( v ) \ | #define CATCH_INTERNAL_CONFIG_SHOW_SUCCESS( v ) \ | ||||||
|     CATCH_INTERNAL_CONFIG_SHOW_SUCCESS2( v, __COUNTER__) |     CATCH_INTERNAL_CONFIG_SHOW_SUCCESS2( v, __COUNTER__) | ||||||
| @@ -278,9 +278,9 @@ private: | |||||||
|         {   CatchOverrides::ConfigGuard cg; \ |         {   CatchOverrides::ConfigGuard cg; \ | ||||||
|             Catch::ConfigData cd(cg.value().get()); \ |             Catch::ConfigData cd(cg.value().get()); \ | ||||||
|             cd.name = name_desc.name; \ |             cd.name = name_desc.name; \ | ||||||
|             cd.showSuccessfulTests = CatchOverrides::Config<Catch::IConfig const*>::instance().includeSuccessfulResults(__FILE__, Count ); \ |             cd.showSuccessfulTests = CatchOverrides::Config<Catch::IConfig const*>::instance().includeSuccessfulResults(__FILE__, __LINE__ ); \ | ||||||
|             cd.warnings            = (CatchOverrides::Config<Catch::IConfig const*>::instance().warnAboutMissingAssertions(__FILE__, Count ) ? Catch::WarnAbout::NoAssertions : Catch::WarnAbout::Nothing); \ |             cd.warnings            = (CatchOverrides::Config<Catch::IConfig const*>::instance().warnAboutMissingAssertions(__FILE__, __LINE__ ) ? Catch::WarnAbout::NoAssertions : Catch::WarnAbout::Nothing); \ | ||||||
|             cd.abortAfter          = CatchOverrides::Config<Catch::IConfig const*>::instance().abortAfter(__FILE__, Count ); \ |             cd.abortAfter          = CatchOverrides::Config<Catch::IConfig const*>::instance().abortAfter(__FILE__, __LINE__ ); \ | ||||||
|             Catch::Ptr<Catch::Config> config(new Catch::Config(cd)); \ |             Catch::Ptr<Catch::Config> config(new Catch::Config(cd)); \ | ||||||
|             Catch::ReporterRegistrar<Catch::MSTestReporter> reporterReg("vs_reporter"); \ |             Catch::ReporterRegistrar<Catch::MSTestReporter> reporterReg("vs_reporter"); \ | ||||||
|             Catch::RunContext context(config.get(), Catch::getRegistryHub().getReporterRegistry().create( "vs_reporter", config.get())); \ |             Catch::RunContext context(config.get(), Catch::getRegistryHub().getReporterRegistry().create( "vs_reporter", config.get())); \ | ||||||
| @@ -300,7 +300,7 @@ private: | |||||||
|     static void INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(); \ |     static void INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(); \ | ||||||
|     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ |     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ | ||||||
|         Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( & INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(CATCH_INTERNAL_HANDLE_EMPTY_PARAM(Name), Desc) ); \ |         Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( & INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(CATCH_INTERNAL_HANDLE_EMPTY_PARAM(Name), Desc) ); \ | ||||||
|         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, Count, 1); \ |         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, __LINE__, 1); \ | ||||||
|         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ |         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ | ||||||
|         { \ |         { \ | ||||||
|             INTERNAL_CATCH_CLASS_CONTEXT \ |             INTERNAL_CATCH_CLASS_CONTEXT \ | ||||||
| @@ -313,7 +313,7 @@ private: | |||||||
|     CHECK_FOR_TEST_CASE_CLASH \ |     CHECK_FOR_TEST_CASE_CLASH \ | ||||||
|     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ |     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ | ||||||
|         Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( & QualifiedMethod, "&" # QualifiedMethod, Catch::NameAndDesc(CATCH_INTERNAL_HANDLE_EMPTY_PARAM(Name), Desc), CATCH_INTERNAL_LINEINFO ); \ |         Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( & QualifiedMethod, "&" # QualifiedMethod, Catch::NameAndDesc(CATCH_INTERNAL_HANDLE_EMPTY_PARAM(Name), Desc), CATCH_INTERNAL_LINEINFO ); \ | ||||||
|         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, Count, 1); \ |         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, __LINE__, 1); \ | ||||||
|         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ |         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ | ||||||
|         { \ |         { \ | ||||||
|             INTERNAL_CATCH_CLASS_CONTEXT \ |             INTERNAL_CATCH_CLASS_CONTEXT \ | ||||||
| @@ -329,7 +329,7 @@ private: | |||||||
|     }; \ |     }; \ | ||||||
|     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ |     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ | ||||||
|         Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( & INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )::invoke, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(CATCH_INTERNAL_HANDLE_EMPTY_PARAM(TestName), Desc) ); \ |         Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( & INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )::invoke, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc(CATCH_INTERNAL_HANDLE_EMPTY_PARAM(TestName), Desc) ); \ | ||||||
|         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, Count, 1); \ |         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, __LINE__, 1); \ | ||||||
|         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ |         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ | ||||||
|         { \ |         { \ | ||||||
|             INTERNAL_CATCH_CLASS_CONTEXT \ |             INTERNAL_CATCH_CLASS_CONTEXT \ | ||||||
| @@ -362,16 +362,16 @@ private: | |||||||
| #define INTERNAL_CATCH_MAP_CATEGORY_TO_TAG2( Category, Tag, Count ) \ | #define INTERNAL_CATCH_MAP_CATEGORY_TO_TAG2( Category, Tag, Count ) \ | ||||||
|     CHECK_FOR_TEST_CASE_CLASH \ |     CHECK_FOR_TEST_CASE_CLASH \ | ||||||
|     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ |     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ | ||||||
|         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, Count, -1); \ |         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, __LINE__, -1); \ | ||||||
|         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ |         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ | ||||||
|         { \ |         { \ | ||||||
|             INTERNAL_CATCH_CLASS_CONTEXT \ |             INTERNAL_CATCH_CLASS_CONTEXT \ | ||||||
| 	        BEGIN_INTERNAL_CATCH_BATCH_METHOD( Category, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) \ | 	        BEGIN_INTERNAL_CATCH_BATCH_METHOD( Category, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) \ | ||||||
|             { \ |             { \ | ||||||
|                 Catch::ConfigData cd; \ |                 Catch::ConfigData cd; \ | ||||||
|                 cd.showSuccessfulTests = CatchOverrides::Config<Catch::IConfig const*>::instance().includeSuccessfulResults(__FILE__, Count ); \ |                 cd.showSuccessfulTests = CatchOverrides::Config<Catch::IConfig const*>::instance().includeSuccessfulResults(__FILE__, __LINE__ ); \ | ||||||
|                 cd.warnings            = (CatchOverrides::Config<Catch::IConfig const*>::instance().warnAboutMissingAssertions(__FILE__, Count ) ? Catch::WarnAbout::NoAssertions : Catch::WarnAbout::Nothing); \ |                 cd.warnings            = (CatchOverrides::Config<Catch::IConfig const*>::instance().warnAboutMissingAssertions(__FILE__, __LINE__ ) ? Catch::WarnAbout::NoAssertions : Catch::WarnAbout::Nothing); \ | ||||||
|                 cd.abortAfter          = CatchOverrides::Config<Catch::IConfig const*>::instance().abortAfter(__FILE__, Count ); \ |                 cd.abortAfter          = CatchOverrides::Config<Catch::IConfig const*>::instance().abortAfter(__FILE__, __LINE__ ); \ | ||||||
|                 cd.reporterName = "vs_reporterlf"; \ |                 cd.reporterName = "vs_reporterlf"; \ | ||||||
|                 cd.name = "Batch run using tag : " Tag; \ |                 cd.name = "Batch run using tag : " Tag; \ | ||||||
|                 cd.testsOrTags.push_back( Tag ); \ |                 cd.testsOrTags.push_back( Tag ); \ | ||||||
| @@ -389,19 +389,19 @@ private: | |||||||
| #define INTERNAL_CATCH_MAP_CATEGORY_TO_LIST2( Category, CategoryName, Count ) \ | #define INTERNAL_CATCH_MAP_CATEGORY_TO_LIST2( Category, CategoryName, Count ) \ | ||||||
|     CHECK_FOR_TEST_CASE_CLASH \ |     CHECK_FOR_TEST_CASE_CLASH \ | ||||||
|     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ |     namespace CATCH_INTERNAL_NAMESPACE( INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) { \ | ||||||
|         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, Count, -1); \ |         CatchOverrides::ConfigReset<Catch::IConfig const*> INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_O_N_F_I_G___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) )(__FILE__, __LINE__, -1); \ | ||||||
|         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ |         INTERNAL_CATCH_CLASS_DEFINITION( INTERNAL_CATCH_UNIQUE_NAME_LINE( C_A_T_C_H____T_E_S_T____C_L_A_S_S___, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) ) \ | ||||||
|         { \ |         { \ | ||||||
|             INTERNAL_CATCH_CLASS_CONTEXT \ |             INTERNAL_CATCH_CLASS_CONTEXT \ | ||||||
| 	        BEGIN_INTERNAL_CATCH_BATCH_METHOD( Category, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) \ | 	        BEGIN_INTERNAL_CATCH_BATCH_METHOD( Category, INTERNAL_CATCH_CONCAT_LINE_COUNTER( Count ) ) \ | ||||||
|             { \ |             { \ | ||||||
|                 Catch::ConfigData cd; \ |                 Catch::ConfigData cd; \ | ||||||
|                 cd.showSuccessfulTests = CatchOverrides::Config<Catch::IConfig const*>::instance().includeSuccessfulResults(__FILE__, Count ); \ |                 cd.showSuccessfulTests = CatchOverrides::Config<Catch::IConfig const*>::instance().includeSuccessfulResults(__FILE__, __LINE__ ); \ | ||||||
|                 cd.warnings            = (CatchOverrides::Config<Catch::IConfig const*>::instance().warnAboutMissingAssertions(__FILE__, Count ) ? Catch::WarnAbout::NoAssertions : Catch::WarnAbout::Nothing); \ |                 cd.warnings            = (CatchOverrides::Config<Catch::IConfig const*>::instance().warnAboutMissingAssertions(__FILE__, __LINE__ ) ? Catch::WarnAbout::NoAssertions : Catch::WarnAbout::Nothing); \ | ||||||
|                 cd.abortAfter          = CatchOverrides::Config<Catch::IConfig const*>::instance().abortAfter(__FILE__, Count ); \ |                 cd.abortAfter          = CatchOverrides::Config<Catch::IConfig const*>::instance().abortAfter(__FILE__, __LINE__ ); \ | ||||||
|                 cd.reporterName = "vs_reporterlf"; \ |                 cd.reporterName = "vs_reporterlf"; \ | ||||||
|                 cd.name = "Batch run using category : " CategoryName; \ |                 cd.name = "Batch run using category : " CategoryName; \ | ||||||
|                 std::vector<std::string> stringNames = CatchOverrides::Config<Catch::IConfig const*>::instance().listOfTests(__FILE__, Count ); \ |                 std::vector<std::string> stringNames = CatchOverrides::Config<Catch::IConfig const*>::instance().listOfTests(__FILE__, __LINE__ ); \ | ||||||
|                 Catch::Ptr<Catch::Config> config(new Catch::Config(cd)); \ |                 Catch::Ptr<Catch::Config> config(new Catch::Config(cd)); \ | ||||||
|                 Catch::ReporterRegistrar<Catch::MSTestReporterLineFeed> reporterReg("vs_reporterlf"); \ |                 Catch::ReporterRegistrar<Catch::MSTestReporterLineFeed> reporterReg("vs_reporterlf"); \ | ||||||
|                 Catch::RunContext context(config.get(), Catch::getRegistryHub().getReporterRegistry().create( "vs_reporterlf", config.get())); \ |                 Catch::RunContext context(config.get(), Catch::getRegistryHub().getReporterRegistry().create( "vs_reporterlf", config.get())); \ | ||||||
|   | |||||||
| @@ -134,7 +134,14 @@ class TestConditionData: | |||||||
| 			if not(reasonOnSameLine) and len(self.reason): | 			if not(reasonOnSameLine) and len(self.reason): | ||||||
| 				lines.append(self.reason) | 				lines.append(self.reason) | ||||||
| 		if len(self.condition): | 		if len(self.condition): | ||||||
| 			lines.append("  " + self.condition) | 			line = self.condition | ||||||
|  | 			m = self.hexParser.match(line) | ||||||
|  | 			if m: | ||||||
|  | 				while m: | ||||||
|  | 					line = m.group(1) + "0x<hex digits>" + m.group(3) | ||||||
|  | 					m = self.hexParser.match(line) | ||||||
|  | 			line = line.replace("__null","0") | ||||||
|  | 			lines.append("  " + line) | ||||||
| 		if len(self.expansionPrefix): | 		if len(self.expansionPrefix): | ||||||
| 			lines.append(self.expansionPrefix) | 			lines.append(self.expansionPrefix) | ||||||
| 			extraLine = True | 			extraLine = True | ||||||
| @@ -145,6 +152,7 @@ class TestConditionData: | |||||||
| 					while m: | 					while m: | ||||||
| 						line = m.group(1) + "0x<hex digits>" + m.group(3) | 						line = m.group(1) + "0x<hex digits>" + m.group(3) | ||||||
| 						m = self.hexParser.match(line) | 						m = self.hexParser.match(line) | ||||||
|  | 				line = line.replace("__null","0") | ||||||
| 				lines.append("  " + line) | 				lines.append("  " + line) | ||||||
| 		if len(self.messagePrefix): | 		if len(self.messagePrefix): | ||||||
| 			lines.append(self.messagePrefix) | 			lines.append(self.messagePrefix) | ||||||
| @@ -223,7 +231,14 @@ class TestConditionData: | |||||||
| 			if not(reasonOnSameLine) and len(self.reason): | 			if not(reasonOnSameLine) and len(self.reason): | ||||||
| 				lines.append(self.reason) | 				lines.append(self.reason) | ||||||
| 		if len(self.condition): | 		if len(self.condition): | ||||||
| 			lines.append("  " + self.condition) | 			line = self.condition | ||||||
|  | 			m = self.hexParser.match(line) | ||||||
|  | 			if m: | ||||||
|  | 				while m: | ||||||
|  | 					line = m.group(1) + "0x<hex digits>" + m.group(3) | ||||||
|  | 					m = self.hexParser.match(line) | ||||||
|  | 			line = line.replace("Catch::Text","Text") | ||||||
|  | 			lines.append("  " + line) | ||||||
| 		if len(self.expansionPrefix): | 		if len(self.expansionPrefix): | ||||||
| 			lines.append(self.expansionPrefix) | 			lines.append(self.expansionPrefix) | ||||||
| 			extraLine = True | 			extraLine = True | ||||||
|   | |||||||
| @@ -44,8 +44,8 @@ def approve( baseName, args ): | |||||||
| 	rawResultsPath = os.path.join( rootPath, '_{0}.tmp'.format( baseName ) ) | 	rawResultsPath = os.path.join( rootPath, '_{0}.tmp'.format( baseName ) ) | ||||||
| 	if os.path.exists( baselinesPath ): | 	if os.path.exists( baselinesPath ): | ||||||
| 		approvedFileHandler = TestRunApprovedHandler(baselinesPath) | 		approvedFileHandler = TestRunApprovedHandler(baselinesPath) | ||||||
| 		baselinesPathNew = os.path.join( rootPath, '{0}.approved.new.txt'.format( baseName ) ) | 		#baselinesPathNew = os.path.join( rootPath, '{0}.approved.new.txt'.format( baseName ) ) | ||||||
| 		approvedFileHandler.writeRawFile(baselinesPathNew) | 		#approvedFileHandler.writeRawFile(baselinesPathNew) | ||||||
| 		approvedFileHandler.writeSortedRawFile(baselinesSortedPath) | 		approvedFileHandler.writeSortedRawFile(baselinesSortedPath) | ||||||
| 	else: | 	else: | ||||||
| 		raise Exception("Base file does not exist: '" + baselinesPath + "'") | 		raise Exception("Base file does not exist: '" + baselinesPath + "'") | ||||||
| @@ -59,11 +59,12 @@ def approve( baseName, args ): | |||||||
|  |  | ||||||
| 	if os.path.exists( rawResultsPath ): | 	if os.path.exists( rawResultsPath ): | ||||||
| 		resultFileHandler = TestRunResultHandler(rawResultsPath) | 		resultFileHandler = TestRunResultHandler(rawResultsPath) | ||||||
| 		rawPathNew = os.path.join( rootPath, '{0}.rewrite.txt'.format( baseName ) ) | 		#rawPathNew = os.path.join( rootPath, '{0}.rewrite.txt'.format( baseName ) ) | ||||||
| 		#print "F:",rawPathNew,",",approvedFileHandler.current.outputLine | 		#print "F:",rawPathNew,",",approvedFileHandler.current.outputLine | ||||||
| 		resultFileHandler.writeRawFile(rawPathNew) | 		#resultFileHandler.writeRawFile(rawPathNew) | ||||||
| 		rawPathNewSorted = os.path.join( rootPath, '{0}.sorted.unapproved.txt'.format( baseName ) ) | 		rawPathNewSorted = os.path.join( rootPath, '{0}.sorted.unapproved.txt'.format( baseName ) ) | ||||||
| 		resultFileHandler.writeSortedUnapprovedFile(rawPathNewSorted, approvedFileHandler.current.outputLine) | 		resultFileHandler.writeSortedUnapprovedFile(rawPathNewSorted, approvedFileHandler.current.outputLine) | ||||||
|  | 		os.remove( rawResultsPath ) | ||||||
| 	else: | 	else: | ||||||
| 		raise Exception("Results file does not exist: '" + rawResultsPath + "'") | 		raise Exception("Results file does not exist: '" + rawResultsPath + "'") | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Malcolm Noyes
					Malcolm Noyes