Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/TestMain.cpp
diff options
context:
space:
mode:
authorPhil Nash2012-08-25 21:26:05 +0100
committerPhil Nash2012-08-25 21:26:05 +0100
commiteb775aa7af1a0734d4588bdaa688aa1cd1605a14 (patch)
treeea817a2330c7292d88bd614286276f10ec5822f5 /projects/SelfTest/TestMain.cpp
parent95ae50ad3dc8d78ddcb6d921d54a6fdeb60a8416 (diff)
downloadcatch3-eb775aa7af1a0734d4588bdaa688aa1cd1605a14.tar.gz
Refactored command line parsers into polymorphic classes
Diffstat (limited to 'projects/SelfTest/TestMain.cpp')
-rw-r--r--projects/SelfTest/TestMain.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp
index ad1f4842..d7031081 100644
--- a/projects/SelfTest/TestMain.cpp
+++ b/projects/SelfTest/TestMain.cpp
@@ -13,7 +13,7 @@
TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results" ) {
using namespace Catch;
-
+
///////////////////////////////////////////////////////////////////////////
SECTION( "selftest/expected result",
"Tests do what they claim" ) {
@@ -70,13 +70,14 @@ TEST_CASE( "meta/Misc/Sections", "looped tests" ) {
template<size_t size>
void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) {
- Catch::parseIntoConfig( Catch::CommandParser( size, argv ), config );
+ static Catch::AllOptions options;
+ options.parseIntoConfig( Catch::CommandParser( size, argv ), config );
}
template<size_t size>
std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::ConfigData& config ) {
try {
- Catch::parseIntoConfig( Catch::CommandParser( size, argv ), config );
+ parseIntoConfig( argv, config );
FAIL( "expected exception" );
}
catch( std::exception& ex ) {
@@ -306,3 +307,30 @@ TEST_CASE( "selftest/filter/wildcard at both ends", "Individual filters with wil
CHECK( matchBadgers.shouldInclude( makeTestCase( "badgers are big" ) ) );
CHECK( matchBadgers.shouldInclude( makeTestCase( "hedgehogs" ) ) == false );
}
+
+
+template<size_t size>
+int getArgc( const char * (&)[size] ) {
+ return size;
+}
+
+TEST_CASE( "selftest/option parsers", "" )
+{
+ Catch::ConfigData config;
+
+ Catch::SharedImpl<Catch::Options::TestCaseOptionParser> tcOpt;
+ Catch::OptionParser& opt = tcOpt;
+
+ const char* argv[] = { "test", "-t", "test1" };
+
+ Catch::CommandParser parser( getArgc( argv ), argv );
+
+ CHECK_NOTHROW( opt.parseIntoConfig( parser, config ) );
+
+ REQUIRE( config.filters.size() == 1 );
+ REQUIRE( config.filters[0].shouldInclude( makeTestCase( "notIncluded" ) ) == false );
+ REQUIRE( config.filters[0].shouldInclude( makeTestCase( "test1" ) ) );
+
+
+
+}