More config refactoring

This commit is contained in:
Phil Nash 2013-05-29 18:34:11 +01:00
parent be8fd82f20
commit 3c3beb57c3
4 changed files with 32 additions and 32 deletions

View File

@ -466,7 +466,7 @@ namespace Catch {
"just pass this option."; "just pass this option.";
} }
virtual void parseIntoConfig( Command const&, ConfigData& config ) { virtual void parseIntoConfig( Command const&, ConfigData& config ) {
config.includeWhichResults = Include::SuccessfulResults; config.showSuccessfulTests = true;
} }
}; };
@ -590,7 +590,7 @@ namespace Catch {
} }
virtual void parseIntoConfig( Command const&, ConfigData& config ) { virtual void parseIntoConfig( Command const&, ConfigData& config ) {
config.allowThrows = false; config.noThrow = true;
} }
}; };

View File

@ -59,17 +59,17 @@ namespace Catch {
ConfigData() ConfigData()
: listSpec( List::None ), : listSpec( List::None ),
includeWhichResults( Include::FailedOnly ), showSuccessfulTests( false ),
shouldDebugBreak( false ), shouldDebugBreak( false ),
allowThrows( true ), noThrow( false ),
cutoff( -1 ), cutoff( -1 ),
warnings( WarnAbout::Nothing ) warnings( WarnAbout::Nothing )
{} {}
List::What listSpec; // !TBD Split into bools List::What listSpec; // !TBD Split into bools
Include::WhichResults includeWhichResults; // !TBD bool bool showSuccessfulTests;
bool shouldDebugBreak; bool shouldDebugBreak;
bool allowThrows; // !TBD invert bool noThrow;
// bool showHelp; // !TBD // bool showHelp; // !TBD
int cutoff; int cutoff;
@ -159,10 +159,10 @@ namespace Catch {
} }
// IConfig interface // IConfig interface
virtual bool allowThrows() const { return m_data.allowThrows; } virtual bool allowThrows() const { return !m_data.noThrow; }
virtual std::ostream& stream() const { return m_os; } virtual std::ostream& stream() const { return m_os; }
virtual std::string name() const { return m_data.name; } virtual std::string name() const { return m_data.name; }
virtual bool includeSuccessfulResults() const { return m_data.includeWhichResults == Include::SuccessfulResults; } virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
virtual bool warnAboutMissingAssertions() const { return m_data.warnings & ConfigData::WarnAbout::NoAssertions; } virtual bool warnAboutMissingAssertions() const { return m_data.warnings & ConfigData::WarnAbout::NoAssertions; }
private: private:

View File

@ -3564,9 +3564,9 @@ with expansion:
TestMain.cpp:102: TestMain.cpp:102:
PASSED: PASSED:
CHECK( config.allowThrows == true ) CHECK( config.noThrow == false )
with expansion: with expansion:
true == true false == false
TestMain.cpp:103: TestMain.cpp:103:
PASSED: PASSED:
@ -3990,9 +3990,9 @@ PASSED:
TestMain.cpp:243: TestMain.cpp:243:
PASSED: PASSED:
REQUIRE( config.allowThrows == false ) REQUIRE( config.noThrow == true )
with expansion: with expansion:
false == false true == true
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
selftest/parser/2 selftest/parser/2
@ -4008,9 +4008,9 @@ PASSED:
TestMain.cpp:249: TestMain.cpp:249:
PASSED: PASSED:
REQUIRE( config.allowThrows == false ) REQUIRE( config.noThrow == true )
with expansion: with expansion:
false == false true == true
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
selftest/parser/2 selftest/parser/2
@ -4104,9 +4104,9 @@ with expansion:
TestMain.cpp:283: TestMain.cpp:283:
PASSED: PASSED:
CHECK( config.allowThrows == false ) CHECK( config.noThrow == true )
with expansion: with expansion:
false == false true == true
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
selftest/test filter selftest/test filter
@ -10636,10 +10636,10 @@ TestMain.cpp" line="101">
</Expression> </Expression>
TestMain.cpp" line="102"> TestMain.cpp" line="102">
<Original> <Original>
config.allowThrows == true config.noThrow == false
</Original> </Original>
<Expanded> <Expanded>
true == true false == false
</Expanded> </Expanded>
</Expression> </Expression>
TestMain.cpp" line="103"> TestMain.cpp" line="103">
@ -11150,10 +11150,10 @@ TestMain.cpp" line="241">
</Expression> </Expression>
TestMain.cpp" line="243"> TestMain.cpp" line="243">
<Original> <Original>
config.allowThrows == false config.noThrow == true
</Original> </Original>
<Expanded> <Expanded>
false == false true == true
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResults successes="2" failures="0"/> <OverallResults successes="2" failures="0"/>
@ -11172,10 +11172,10 @@ TestMain.cpp" line="247">
</Expression> </Expression>
TestMain.cpp" line="249"> TestMain.cpp" line="249">
<Original> <Original>
config.allowThrows == false config.noThrow == true
</Original> </Original>
<Expanded> <Expanded>
false == false true == true
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResults successes="2" failures="0"/> <OverallResults successes="2" failures="0"/>
@ -11298,10 +11298,10 @@ TestMain.cpp" line="282">
</Expression> </Expression>
TestMain.cpp" line="283"> TestMain.cpp" line="283">
<Original> <Original>
config.allowThrows == false config.noThrow == true
</Original> </Original>
<Expanded> <Expanded>
false == false true == true
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResults successes="4" failures="0"/> <OverallResults successes="4" failures="0"/>
@ -14258,7 +14258,7 @@ TestMain.cpp:59: totals.assertions.failed == 1 succeeded for: 1 == 1
TestMain.cpp:98: parseIntoConfig( argv, config ) succeeded TestMain.cpp:98: parseIntoConfig( argv, config ) succeeded
TestMain.cpp:100: config.shouldDebugBreak == false succeeded for: false == false TestMain.cpp:100: config.shouldDebugBreak == false succeeded for: false == false
TestMain.cpp:101: config.cutoff == -1 succeeded for: -1 == -1 TestMain.cpp:101: config.cutoff == -1 succeeded for: -1 == -1
TestMain.cpp:102: config.allowThrows == true succeeded for: true == true TestMain.cpp:102: config.noThrow == false succeeded for: false == false
TestMain.cpp:103: config.reporter.empty() succeeded for: true TestMain.cpp:103: config.reporter.empty() succeeded for: true
[End of section: 'default' All 5 assertions passed] [End of section: 'default' All 5 assertions passed]
@ -14430,7 +14430,7 @@ TestMain.cpp:234: parseIntoConfigAndReturnError( argv, config ) Contains( "0 and
[Started section: 'nothrow'] [Started section: 'nothrow']
[Started section: '-nt'] [Started section: '-nt']
TestMain.cpp:241: parseIntoConfig( argv, config ) succeeded TestMain.cpp:241: parseIntoConfig( argv, config ) succeeded
TestMain.cpp:243: config.allowThrows == false succeeded for: false == false TestMain.cpp:243: config.noThrow == true succeeded for: true == true
[End of section: '-nt' All 2 assertions passed] [End of section: '-nt' All 2 assertions passed]
[End of section: 'nothrow' All 2 assertions passed] [End of section: 'nothrow' All 2 assertions passed]
@ -14438,7 +14438,7 @@ TestMain.cpp:243: config.allowThrows == false succeeded for: false == false
[Started section: 'nothrow'] [Started section: 'nothrow']
[Started section: '--nothrow'] [Started section: '--nothrow']
TestMain.cpp:247: parseIntoConfig( argv, config ) succeeded TestMain.cpp:247: parseIntoConfig( argv, config ) succeeded
TestMain.cpp:249: config.allowThrows == false succeeded for: false == false TestMain.cpp:249: config.noThrow == true succeeded for: true == true
[End of section: '--nothrow' All 2 assertions passed] [End of section: '--nothrow' All 2 assertions passed]
[End of section: 'nothrow' All 2 assertions passed] [End of section: 'nothrow' All 2 assertions passed]
@ -14474,7 +14474,7 @@ TestMain.cpp:272: config.outputFilename == "filename.ext" succeeded for: "filena
TestMain.cpp:279: parseIntoConfig( argv, config ) succeeded TestMain.cpp:279: parseIntoConfig( argv, config ) succeeded
TestMain.cpp:281: config.cutoff == 1 succeeded for: 1 == 1 TestMain.cpp:281: config.cutoff == 1 succeeded for: 1 == 1
TestMain.cpp:282: config.shouldDebugBreak succeeded for: true TestMain.cpp:282: config.shouldDebugBreak succeeded for: true
TestMain.cpp:283: config.allowThrows == false succeeded for: false == false TestMain.cpp:283: config.noThrow == true succeeded for: true == true
[End of section: '-a -b' All 4 assertions passed] [End of section: '-a -b' All 4 assertions passed]
[End of section: 'combinations' All 4 assertions passed] [End of section: 'combinations' All 4 assertions passed]

View File

@ -99,7 +99,7 @@ TEST_CASE( "selftest/parser/2", "ConfigData" ) {
CHECK( config.shouldDebugBreak == false ); CHECK( config.shouldDebugBreak == false );
CHECK( config.cutoff == -1 ); CHECK( config.cutoff == -1 );
CHECK( config.allowThrows == true ); CHECK( config.noThrow == false );
CHECK( config.reporter.empty() ); CHECK( config.reporter.empty() );
} }
@ -240,13 +240,13 @@ TEST_CASE( "selftest/parser/2", "ConfigData" ) {
const char* argv[] = { "test", "-nt" }; const char* argv[] = { "test", "-nt" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) ); CHECK_NOTHROW( parseIntoConfig( argv, config ) );
REQUIRE( config.allowThrows == false ); REQUIRE( config.noThrow == true );
} }
SECTION( "--nothrow", "" ) { SECTION( "--nothrow", "" ) {
const char* argv[] = { "test", "--nothrow" }; const char* argv[] = { "test", "--nothrow" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) ); CHECK_NOTHROW( parseIntoConfig( argv, config ) );
REQUIRE( config.allowThrows == false ); REQUIRE( config.noThrow == true );
} }
} }
@ -280,7 +280,7 @@ TEST_CASE( "selftest/parser/2", "ConfigData" ) {
CHECK( config.cutoff == 1 ); CHECK( config.cutoff == 1 );
CHECK( config.shouldDebugBreak ); CHECK( config.shouldDebugBreak );
CHECK( config.allowThrows == false ); CHECK( config.noThrow == true );
} }
} }
} }