Added BDD macros

(Also includes regenerated files from previous commits)
This commit is contained in:
Phil Nash 2013-03-13 12:19:30 +00:00
parent 0db35c0f35
commit 37186a1d04
4 changed files with 437 additions and 451 deletions

View File

@ -88,6 +88,14 @@
#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) #define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
// "BDD-style" convenience wrappers
#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags )
#define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" )
#define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" )
#define CATCH_AND_WHEN( desc ) CATCH_SECTION( " And: " desc, "" )
#define CATCH_THEN( desc ) CATCH_SECTION( " Then: " desc, "" )
#define CATCH_AND_THEN( desc ) CATCH_SECTION( " And: " desc, "" )
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required // If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
#else #else
@ -135,6 +143,14 @@
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
// "BDD-style" convenience wrappers
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
#define GIVEN( desc ) SECTION( "Given: " desc, "" )
#define WHEN( desc ) SECTION( " When: " desc, "" )
#define AND_WHEN( desc ) SECTION( " And: " desc, "" )
#define THEN( desc ) SECTION( " Then: " desc, "" )
#define AND_THEN( desc ) SECTION( " And: " desc, "" )
using Catch::Detail::Approx; using Catch::Detail::Approx;
#ifdef __clang__ #ifdef __clang__

File diff suppressed because it is too large Load Diff

View File

@ -8,14 +8,6 @@
#include "catch.hpp" #include "catch.hpp"
// !TBD: story scenarios map to class based tests
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
#define GIVEN( desc ) SECTION( "Given: " desc, "" )
#define WHEN( desc ) SECTION( " When: " desc, "" )
#define AND_WHEN( desc ) SECTION( " And: " desc, "" )
#define THEN( desc ) SECTION( " Then: " desc, "" )
#define AND_THEN( desc ) SECTION( " And: " desc, "" )
inline bool itDoesThis(){ return true; } inline bool itDoesThis(){ return true; }
inline bool itDoesThat(){ return true; } inline bool itDoesThat(){ return true; }

View File

@ -1,6 +1,6 @@
/* /*
* CATCH v0.9 build 24 (integration branch) * CATCH v0.9 build 24 (integration branch)
* Generated: 2013-03-12 18:45:29.590076 * Generated: 2013-03-13 12:18:41.022404
* ---------------------------------------------------------- * ----------------------------------------------------------
* 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.
@ -256,6 +256,11 @@ namespace Catch {
// #included from: catch_ptr.hpp // #included from: catch_ptr.hpp
#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED #define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#endif
namespace Catch { namespace Catch {
// An intrusive reference counting smart pointer. // An intrusive reference counting smart pointer.
@ -328,6 +333,10 @@ namespace Catch {
} // end namespace Catch } // end namespace Catch
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#include <vector> #include <vector>
namespace Catch { namespace Catch {
@ -1323,6 +1332,11 @@ inline void writeToDebugConsole( const std::string& text ) {
#include <string> #include <string>
#include <set> #include <set>
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#endif
namespace Catch { namespace Catch {
struct ITestCase; struct ITestCase;
@ -1378,6 +1392,10 @@ namespace Catch {
const SourceLineInfo& lineInfo ); const SourceLineInfo& lineInfo );
} }
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// #included from: catch_tags.hpp // #included from: catch_tags.hpp
#define TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED #define TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED
@ -2217,6 +2235,8 @@ namespace Catch
virtual ReporterPreferences getPreferences() const = 0; virtual ReporterPreferences getPreferences() const = 0;
virtual void noMatchingTestCases( std::string const& spec ) = 0;
virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0;
virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0;
@ -2241,6 +2261,8 @@ namespace Catch
virtual ~StreamingReporterBase(); virtual ~StreamingReporterBase();
virtual void noMatchingTestCases( std::string const& ) {}
virtual void testRunStarting( TestRunInfo const& _testRunInfo ) { virtual void testRunStarting( TestRunInfo const& _testRunInfo ) {
testRunInfo = _testRunInfo; testRunInfo = _testRunInfo;
} }
@ -2306,70 +2328,6 @@ namespace Catch
std::vector<TestGroupNode> groups; std::vector<TestGroupNode> groups;
}; };
// !TBD: Derived helper that implements the streaming interface but holds the stats
// - declares a new interface where methods are called at the end of each event
// - this would be used by the JUnit reporter, for example.
// - it may be used by the basic reporter, too, but that would clear down the stack
// as it goes
struct CumulativeReporterBase : SharedImpl<IStreamingReporter> {
CumulativeReporterBase( ReporterConfig const& _config )
: m_config( _config ),
stream( _config.stream() )
{}
virtual ~CumulativeReporterBase();
virtual void testRunStarting( TestRunInfo const& _testRunInfo ) {
// testRunInfo = _testRunInfo;
}
virtual void testGroupStarting( GroupInfo const& _groupInfo ) {
testGroupNode = TestGroupNode( _groupInfo );
}
virtual void testCaseStarting( TestCaseInfo const& _testInfo ) {
// unusedTestCaseInfo = _testInfo;
}
virtual void sectionStarting( SectionInfo const& _sectionInfo ) {
// Ptr<ThreadedSectionInfo> sectionInfo = new ThreadedSectionInfo( _sectionInfo );
// if( !currentSectionInfo ) {
// currentSectionInfo = sectionInfo;
// }
// else {
// currentSectionInfo->children.push_back( sectionInfo );
// sectionInfo->parent = currentSectionInfo;
// currentSectionInfo = sectionInfo;
// }
}
virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) {
// currentSectionInfo = currentSectionInfo->parent;
}
virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) {
// unusedTestCaseInfo.reset();
}
virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) {
// testGroupNode-> // populate
// Ptr<TestGroupNode> node ( new TestGroupNode( _testGroupStats ) );
// unusedGroupInfo.reset();
}
virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) {
// currentSectionInfo.reset();
// unusedTestCaseInfo.reset();
// unusedGroupInfo.reset();
// testRunInfo.reset();
}
ReporterConfig m_config;
// Option<TestRunInfo> testRunInfo;
// Option<GroupInfo> unusedGroupInfo;
// Option<TestCaseInfo> unusedTestCaseInfo;
// Ptr<ThreadedSectionInfo> currentSectionInfo;
// Ptr<TestGroupNode> testGroupNode;
Option<TestGroupNode> testGroupNode;
std::ostream& stream;
};
// Deprecated // Deprecated
struct IReporter : IShared { struct IReporter : IShared {
virtual ~IReporter(); virtual ~IReporter();
@ -2405,6 +2363,7 @@ namespace Catch
return prefs; return prefs;
} }
virtual void noMatchingTestCases( std::string const& ) {}
virtual void testRunStarting( TestRunInfo const& ) { virtual void testRunStarting( TestRunInfo const& ) {
m_legacyReporter->StartTesting(); m_legacyReporter->StartTesting();
} }
@ -4785,7 +4744,7 @@ namespace Catch {
} }
} }
if( testsRunForGroup == 0 && !filterGroup.getName().empty() ) if( testsRunForGroup == 0 && !filterGroup.getName().empty() )
std::cerr << "\n[No test cases matched with: " << filterGroup.getName() << "]" << std::endl; m_reporter->noMatchingTestCases( filterGroup.getName() );
return totals; return totals;
} }
@ -6952,7 +6911,7 @@ namespace Catch {
private: private:
ReporterConfig m_config; ReporterConfig m_config;
bool m_currentTestSuccess; // bool m_currentTestSuccess;
Stats m_testSuiteStats; Stats m_testSuiteStats;
Stats* m_currentStats; Stats* m_currentStats;
@ -6987,6 +6946,10 @@ namespace Catch {
} }
virtual void noMatchingTestCases( std::string const& spec ) {
stream << "No test cases matched '" << spec << "'" << std::endl;
}
virtual void assertionStarting( AssertionInfo const& ) { virtual void assertionStarting( AssertionInfo const& ) {
} }
@ -7368,7 +7331,6 @@ namespace Catch {
BasicReporter::~BasicReporter() {} BasicReporter::~BasicReporter() {}
StreamingReporterBase::~StreamingReporterBase() {} StreamingReporterBase::~StreamingReporterBase() {}
CumulativeReporterBase::~CumulativeReporterBase() {}
ConsoleReporter::~ConsoleReporter() {} ConsoleReporter::~ConsoleReporter() {}
IRunner::~IRunner() {} IRunner::~IRunner() {}
IMutableContext::~IMutableContext() {} IMutableContext::~IMutableContext() {}
@ -7480,6 +7442,14 @@ int main (int argc, char * const argv[]) {
#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) #define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
// "BDD-style" convenience wrappers
#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags )
#define CATCH_GIVEN( desc ) CATCH_SECTION( "Given: " desc, "" )
#define CATCH_WHEN( desc ) CATCH_SECTION( " When: " desc, "" )
#define CATCH_AND_WHEN( desc ) CATCH_SECTION( " And: " desc, "" )
#define CATCH_THEN( desc ) CATCH_SECTION( " Then: " desc, "" )
#define CATCH_AND_THEN( desc ) CATCH_SECTION( " And: " desc, "" )
// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required // If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required
#else #else
@ -7527,6 +7497,14 @@ int main (int argc, char * const argv[]) {
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
// "BDD-style" convenience wrappers
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
#define GIVEN( desc ) SECTION( "Given: " desc, "" )
#define WHEN( desc ) SECTION( " When: " desc, "" )
#define AND_WHEN( desc ) SECTION( " And: " desc, "" )
#define THEN( desc ) SECTION( " Then: " desc, "" )
#define AND_THEN( desc ) SECTION( " And: " desc, "" )
using Catch::Detail::Approx; using Catch::Detail::Approx;
#ifdef __clang__ #ifdef __clang__