Completed embedded docs

This commit is contained in:
Phil Nash 2012-09-09 11:44:30 +01:00
parent dae5808666
commit f7418eb2dd
2 changed files with 288 additions and 120 deletions

View File

@ -221,7 +221,8 @@ namespace Catch {
// Tab chars are removed from the output but their positions are used to align // Tab chars are removed from the output but their positions are used to align
// subsequently wrapped lines // subsequently wrapped lines
virtual std::string optionDescription() const { virtual std::string optionDescription() const {
return "This option allows one ore more test specs to be supplied. Each spec either fully " return
"This option allows one ore more test specs to be supplied. Each spec either fully "
"specifies a test case or is a pattern containing wildcards to match a set of test " "specifies a test case or is a pattern containing wildcards to match a set of test "
"cases. If this option is not provided then all test cases, except those prefixed " "cases. If this option is not provided then all test cases, except those prefixed "
"by './' are run\n" "by './' are run\n"
@ -245,7 +246,7 @@ namespace Catch {
" -t exclude:notThis \tMatches all tests except, 'notThis'\n" " -t exclude:notThis \tMatches all tests except, 'notThis'\n"
" -t ~notThis \tMatches all tests except, 'notThis'\n" " -t ~notThis \tMatches all tests except, 'notThis'\n"
" -t ~*private* \tMatches all tests except those that contain 'private'\n" " -t ~*private* \tMatches all tests except those that contain 'private'\n"
" -t a/* ~a/b/* a/b/c \tMatches all tests that start with 'a/', except those" " -t a/* ~a/b/* a/b/c \tMatches all tests that start with 'a/', except those "
"that start with 'a/b/', except 'a/b/c', which is included"; "that start with 'a/b/', except 'a/b/c', which is included";
} }
@ -277,7 +278,8 @@ namespace Catch {
} }
virtual std::string optionDescription() const { virtual std::string optionDescription() const {
return "With no arguments this option will list all registered tests - one per line.\n" return
"With no arguments this option will list all registered tests - one per line.\n"
"Supplying the xml argument formats the list as an xml document (which may be useful for " "Supplying the xml argument formats the list as an xml document (which may be useful for "
"consumption by other tools).\n" "consumption by other tools).\n"
"Supplying the tests or reporters lists tests or reporters respectively - with descriptions.\n" "Supplying the tests or reporters lists tests or reporters respectively - with descriptions.\n"
@ -327,7 +329,8 @@ namespace Catch {
} }
virtual std::string optionDescription() const { virtual std::string optionDescription() const {
return "A reporter is an object that formats and structures the output of running " return
"A reporter is an object that formats and structures the output of running "
"tests, and potentially summarises the results. By default a basic reporter " "tests, and potentially summarises the results. By default a basic reporter "
"is used that writes IDE friendly results. CATCH comes bundled with some " "is used that writes IDE friendly results. CATCH comes bundled with some "
"alternative reporters, but more can be added in client code.\n" "alternative reporters, but more can be added in client code.\n"
@ -363,7 +366,23 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Sends output to a file or stream"; return "Sends output to a file or stream";
} }
virtual std::string optionDescription() const {
return
"Use this option to send all output to a file or a stream. By default output is "
"sent to stdout (note that uses ofstdout and stderr from within test cases are "
"redirected and included in the report - so even stderr will effectively end up "
"on stdout). If the name begins with % it is interpretted as a stream. "
"Otherwise it is treated as a filename.\n"
"\n"
"Examples are:\n"
"\n"
" -o filename.txt\n"
" -o \"long filename.txt\"\n"
" -o %stdout\n"
" -o %stderr\n"
" -o %debug \t(The IDE's debug output window - currently only Windows' "
"OutputDebugString is supported).";
}
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
if( cmd[0][0] == '%' ) if( cmd[0][0] == '%' )
config.stream = cmd[0].substr( 1 ); config.stream = cmd[0].substr( 1 );
@ -372,9 +391,9 @@ namespace Catch {
} }
}; };
class SuccesssOptionParser : public OptionParser { class SuccessOptionParser : public OptionParser {
public: public:
SuccesssOptionParser() { SuccessOptionParser() {
m_optionNames.push_back( "-s" ); m_optionNames.push_back( "-s" );
m_optionNames.push_back( "--success" ); m_optionNames.push_back( "--success" );
} }
@ -384,7 +403,13 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Shows results for successful tests"; return "Shows results for successful tests";
} }
virtual std::string optionDescription() const {
return
"Usually you only want to see reporting for failed tests. Sometimes it's useful "
"to see all the output (especially when you don't trust that that test you just "
"added worked first time!). To see successul, as well as failing, test results "
"just pass this option.";
}
virtual void parseIntoConfig( const Command&, ConfigData& config ) { virtual void parseIntoConfig( const Command&, ConfigData& config ) {
config.includeWhichResults = Include::SuccessfulResults; config.includeWhichResults = Include::SuccessfulResults;
} }
@ -402,6 +427,14 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Breaks into the debugger on failure"; return "Breaks into the debugger on failure";
} }
virtual std::string optionDescription() const {
return
"In some IDEs (currently XCode and Visual Studio) it is possible for CATCH to "
"break into the debugger on a test failure. This can be very helpful during "
"debug sessions - especially when there is more than one path through a "
"particular test. In addition to the command line option, ensure you have "
"built your code with the DEBUG preprocessor symbol";
}
virtual void parseIntoConfig( const Command&, ConfigData& config ) { virtual void parseIntoConfig( const Command&, ConfigData& config ) {
config.shouldDebugBreak = true; config.shouldDebugBreak = true;
@ -420,6 +453,18 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Names a test run"; return "Names a test run";
} }
virtual std::string optionDescription() const {
return
"If a name is supplied it will be used by the reporter to provide an overall "
"name for the test run. This can be useful if you are sending to a file, for "
"example, and need to distinguish different test runs - either from different "
"Catch executables or runs of the same executable with different options.\n"
"\n"
"Examples:\n"
"\n"
" -n testRun\n"
" -n \"tests of the widget component\"";
}
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
config.name = cmd[0]; config.name = cmd[0];
@ -438,6 +483,17 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Aborts after a certain number of failures"; return "Aborts after a certain number of failures";
} }
virtual std::string optionDescription() const {
return
"If a REQUIRE assertion fails the test case aborts, but subsequent test cases "
"are still run. If a CHECK assertion fails even the current test case is not "
"aborted.\n"
"\n"
"Sometimes this results in a flood of failure messages and you'd rather just "
"see the first few. Specifying -a or --abort on its own will abort the whole "
"test run on the first failed assertion of any kind. Following it with a "
"number causes it to abort after that number of assertion failures.";
}
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
int threshold = 1; int threshold = 1;
@ -464,6 +520,19 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Elides assertions expected to throw"; return "Elides assertions expected to throw";
} }
virtual std::string optionDescription() const {
return
"Skips all assertions that test that an exception is thrown, "
"e.g. REQUIRE_THROWS.\n"
"\n"
"These can be a nuisance in certain debugging environments that may break when "
"exceptions are thrown (while this is usually optional for handled exceptions, "
"it can be useful to have enabled if you are trying to track down something "
"unexpected).\n"
"\n"
"When running with this option the throw checking assertions are skipped so "
"as not to contribute additional noise.";
}
virtual void parseIntoConfig( const Command&, ConfigData& config ) { virtual void parseIntoConfig( const Command&, ConfigData& config ) {
config.allowThrows = false; config.allowThrows = false;
@ -482,6 +551,19 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Enable warnings"; return "Enable warnings";
} }
virtual std::string optionDescription() const {
return
"Enables the named warnings. If the warnings are violated the test case is "
"failed.\n"
"\n"
"At present only one warning has been provided: NoAssertions. If this warning "
"is enabled then any test case that completes without an assertions (CHECK, "
"REQUIRE etc) being encountered violates the warning.\n"
"\n"
"e.g.:\n"
"\n"
" -w NoAssertions";
}
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) { for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
@ -507,7 +589,7 @@ namespace Catch {
add<Options::ListOptionParser>(); add<Options::ListOptionParser>();
add<Options::ReporterOptionParser>(); add<Options::ReporterOptionParser>();
add<Options::OutputOptionParser>(); add<Options::OutputOptionParser>();
add<Options::SuccesssOptionParser>(); add<Options::SuccessOptionParser>();
add<Options::DebugBreakOptionParser>(); add<Options::DebugBreakOptionParser>();
add<Options::NameOptionParser>(); add<Options::NameOptionParser>();
add<Options::AbortOptionParser>(); add<Options::AbortOptionParser>();

View File

@ -1,5 +1,5 @@
/* /*
* Generated: 2012-09-07 17:50:08.286409 * Generated: 2012-09-09 11:44:01.394438
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -2731,7 +2731,8 @@ namespace Catch {
// Tab chars are removed from the output but their positions are used to align // Tab chars are removed from the output but their positions are used to align
// subsequently wrapped lines // subsequently wrapped lines
virtual std::string optionDescription() const { virtual std::string optionDescription() const {
return "This option allows one ore more test specs to be supplied. Each spec either fully " return
"This option allows one ore more test specs to be supplied. Each spec either fully "
"specifies a test case or is a pattern containing wildcards to match a set of test " "specifies a test case or is a pattern containing wildcards to match a set of test "
"cases. If this option is not provided then all test cases, except those prefixed " "cases. If this option is not provided then all test cases, except those prefixed "
"by './' are run\n" "by './' are run\n"
@ -2755,7 +2756,7 @@ namespace Catch {
" -t exclude:notThis \tMatches all tests except, 'notThis'\n" " -t exclude:notThis \tMatches all tests except, 'notThis'\n"
" -t ~notThis \tMatches all tests except, 'notThis'\n" " -t ~notThis \tMatches all tests except, 'notThis'\n"
" -t ~*private* \tMatches all tests except those that contain 'private'\n" " -t ~*private* \tMatches all tests except those that contain 'private'\n"
" -t a/* ~a/b/* a/b/c \tMatches all tests that start with 'a/', except those" " -t a/* ~a/b/* a/b/c \tMatches all tests that start with 'a/', except those "
"that start with 'a/b/', except 'a/b/c', which is included"; "that start with 'a/b/', except 'a/b/c', which is included";
} }
@ -2787,7 +2788,8 @@ namespace Catch {
} }
virtual std::string optionDescription() const { virtual std::string optionDescription() const {
return "With no arguments this option will list all registered tests - one per line.\n" return
"With no arguments this option will list all registered tests - one per line.\n"
"Supplying the xml argument formats the list as an xml document (which may be useful for " "Supplying the xml argument formats the list as an xml document (which may be useful for "
"consumption by other tools).\n" "consumption by other tools).\n"
"Supplying the tests or reporters lists tests or reporters respectively - with descriptions.\n" "Supplying the tests or reporters lists tests or reporters respectively - with descriptions.\n"
@ -2837,7 +2839,8 @@ namespace Catch {
} }
virtual std::string optionDescription() const { virtual std::string optionDescription() const {
return "A reporter is an object that formats and structures the output of running " return
"A reporter is an object that formats and structures the output of running "
"tests, and potentially summarises the results. By default a basic reporter " "tests, and potentially summarises the results. By default a basic reporter "
"is used that writes IDE friendly results. CATCH comes bundled with some " "is used that writes IDE friendly results. CATCH comes bundled with some "
"alternative reporters, but more can be added in client code.\n" "alternative reporters, but more can be added in client code.\n"
@ -2873,7 +2876,23 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Sends output to a file or stream"; return "Sends output to a file or stream";
} }
virtual std::string optionDescription() const {
return
"Use this option to send all output to a file or a stream. By default output is "
"sent to stdout (note that uses ofstdout and stderr from within test cases are "
"redirected and included in the report - so even stderr will effectively end up "
"on stdout). If the name begins with % it is interpretted as a stream. "
"Otherwise it is treated as a filename.\n"
"\n"
"Examples are:\n"
"\n"
" -o filename.txt\n"
" -o \"long filename.txt\"\n"
" -o %stdout\n"
" -o %stderr\n"
" -o %debug \t(The IDE's debug output window - currently only Windows' "
"OutputDebugString is supported).";
}
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
if( cmd[0][0] == '%' ) if( cmd[0][0] == '%' )
config.stream = cmd[0].substr( 1 ); config.stream = cmd[0].substr( 1 );
@ -2882,9 +2901,9 @@ namespace Catch {
} }
}; };
class SuccesssOptionParser : public OptionParser { class SuccessOptionParser : public OptionParser {
public: public:
SuccesssOptionParser() { SuccessOptionParser() {
m_optionNames.push_back( "-s" ); m_optionNames.push_back( "-s" );
m_optionNames.push_back( "--success" ); m_optionNames.push_back( "--success" );
} }
@ -2894,7 +2913,13 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Shows results for successful tests"; return "Shows results for successful tests";
} }
virtual std::string optionDescription() const {
return
"Usually you only want to see reporting for failed tests. Sometimes it's useful "
"to see all the output (especially when you don't trust that that test you just "
"added worked first time!). To see successul, as well as failing, test results "
"just pass this option.";
}
virtual void parseIntoConfig( const Command&, ConfigData& config ) { virtual void parseIntoConfig( const Command&, ConfigData& config ) {
config.includeWhichResults = Include::SuccessfulResults; config.includeWhichResults = Include::SuccessfulResults;
} }
@ -2912,6 +2937,14 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Breaks into the debugger on failure"; return "Breaks into the debugger on failure";
} }
virtual std::string optionDescription() const {
return
"In some IDEs (currently XCode and Visual Studio) it is possible for CATCH to "
"break into the debugger on a test failure. This can be very helpful during "
"debug sessions - especially when there is more than one path through a "
"particular test. In addition to the command line option, ensure you have "
"built your code with the DEBUG preprocessor symbol";
}
virtual void parseIntoConfig( const Command&, ConfigData& config ) { virtual void parseIntoConfig( const Command&, ConfigData& config ) {
config.shouldDebugBreak = true; config.shouldDebugBreak = true;
@ -2930,6 +2963,18 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Names a test run"; return "Names a test run";
} }
virtual std::string optionDescription() const {
return
"If a name is supplied it will be used by the reporter to provide an overall "
"name for the test run. This can be useful if you are sending to a file, for "
"example, and need to distinguish different test runs - either from different "
"Catch executables or runs of the same executable with different options.\n"
"\n"
"Examples:\n"
"\n"
" -n testRun\n"
" -n \"tests of the widget component\"";
}
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
config.name = cmd[0]; config.name = cmd[0];
@ -2948,6 +2993,17 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Aborts after a certain number of failures"; return "Aborts after a certain number of failures";
} }
virtual std::string optionDescription() const {
return
"If a REQUIRE assertion fails the test case aborts, but subsequent test cases "
"are still run. If a CHECK assertion fails even the current test case is not "
"aborted.\n"
"\n"
"Sometimes this results in a flood of failure messages and you'd rather just "
"see the first few. Specifying -a or --abort on its own will abort the whole "
"test run on the first failed assertion of any kind. Following it with a "
"number causes it to abort after that number of assertion failures.";
}
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
int threshold = 1; int threshold = 1;
@ -2974,6 +3030,19 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Elides assertions expected to throw"; return "Elides assertions expected to throw";
} }
virtual std::string optionDescription() const {
return
"Skips all assertions that test that an exception is thrown, "
"e.g. REQUIRE_THROWS.\n"
"\n"
"These can be a nuisance in certain debugging environments that may break when "
"exceptions are thrown (while this is usually optional for handled exceptions, "
"it can be useful to have enabled if you are trying to track down something "
"unexpected).\n"
"\n"
"When running with this option the throw checking assertions are skipped so "
"as not to contribute additional noise.";
}
virtual void parseIntoConfig( const Command&, ConfigData& config ) { virtual void parseIntoConfig( const Command&, ConfigData& config ) {
config.allowThrows = false; config.allowThrows = false;
@ -2992,6 +3061,19 @@ namespace Catch {
virtual std::string optionSummary() const { virtual std::string optionSummary() const {
return "Enable warnings"; return "Enable warnings";
} }
virtual std::string optionDescription() const {
return
"Enables the named warnings. If the warnings are violated the test case is "
"failed.\n"
"\n"
"At present only one warning has been provided: NoAssertions. If this warning "
"is enabled then any test case that completes without an assertions (CHECK, "
"REQUIRE etc) being encountered violates the warning.\n"
"\n"
"e.g.:\n"
"\n"
" -w NoAssertions";
}
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) { for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
@ -3017,7 +3099,7 @@ namespace Catch {
add<Options::ListOptionParser>(); add<Options::ListOptionParser>();
add<Options::ReporterOptionParser>(); add<Options::ReporterOptionParser>();
add<Options::OutputOptionParser>(); add<Options::OutputOptionParser>();
add<Options::SuccesssOptionParser>(); add<Options::SuccessOptionParser>();
add<Options::DebugBreakOptionParser>(); add<Options::DebugBreakOptionParser>();
add<Options::NameOptionParser>(); add<Options::NameOptionParser>();
add<Options::AbortOptionParser>(); add<Options::AbortOptionParser>();
@ -3763,6 +3845,7 @@ namespace Catch {
addIndent( os, indent ); addIndent( os, indent );
os << paragraph << "\n"; os << paragraph << "\n";
} }
inline std::string addLineBreaks( const std::string& str, std::size_t columns, std::size_t indent = 0 ) { inline std::string addLineBreaks( const std::string& str, std::size_t columns, std::size_t indent = 0 ) {
std::ostringstream oss; std::ostringstream oss;
std::string::size_type pos = 0; std::string::size_type pos = 0;
@ -3773,6 +3856,9 @@ namespace Catch {
pos = newline+1; pos = newline+1;
newline = str.find_first_of( '\n', pos ); newline = str.find_first_of( '\n', pos );
} }
if( pos != str.size() )
recursivelyWrapLine( oss, str.substr( pos, str.size()-pos ), columns, indent );
return oss.str(); return oss.str();
} }