First cut of Timer class.

- started integrating with reporters (now (optionally) supported in console reporter).
- introduced Node<> template to help with cumulative reporting and used it instead of ThreadedSectionInfo.
This commit is contained in:
Phil Nash 2013-08-07 18:56:35 +01:00
parent 649f8c24b1
commit 6339254cb2
16 changed files with 379 additions and 174 deletions

View File

@ -24,15 +24,21 @@ namespace Catch {
inline void addWarning( ConfigData& config, std::string const& _warning ) {
if( _warning == "NoAssertions" )
config.warnings = (ConfigData::WarnAbout::What)( config.warnings | ConfigData::WarnAbout::NoAssertions );
config.warnings = (WarnAbout::What)( config.warnings | WarnAbout::NoAssertions );
else
throw std::runtime_error( "Unrecognised warning: '" + _warning + "'" );
}
inline void setVerbosity( ConfigData& config, int level ) {
// !TBD: accept strings?
config.verbosity = (ConfigData::Verbosity::Level)level;
config.verbosity = (Verbosity::Level)level;
}
inline void setShowDurations( ConfigData& config, bool _showDurations ) {
config.showDurations = _showDurations
? ShowDurations::Always
: ShowDurations::Never;
}
inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
@ -121,6 +127,12 @@ namespace Catch {
.describe( "which test or tests to use" )
.argName( "test name, pattern or tags" );
cli.bind( &setShowDurations )
.describe( "show test durations" )
.shortOpt( "d")
.longOpt( "durations" )
.argName( "durations" );
return cli;
}

View File

@ -26,17 +26,6 @@ namespace Catch {
struct ConfigData {
struct Verbosity { enum Level {
NoOutput = 0,
Quiet,
Normal
}; };
struct WarnAbout { enum What {
Nothing = 0x00,
NoAssertions = 0x01
}; };
ConfigData()
: listTests( false ),
listTags( false ),
@ -47,7 +36,8 @@ namespace Catch {
showHelp( false ),
abortAfter( -1 ),
verbosity( Verbosity::Normal ),
warnings( WarnAbout::Nothing )
warnings( WarnAbout::Nothing ),
showDurations( ShowDurations::DefaultForReporter )
{}
bool listTests;
@ -63,6 +53,7 @@ namespace Catch {
Verbosity::Level verbosity;
WarnAbout::What warnings;
ShowDurations::OrNot showDurations;
std::string reporterName;
std::string outputFilename;
@ -166,7 +157,9 @@ namespace Catch {
virtual std::ostream& stream() const { return m_os; }
virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
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 & WarnAbout::NoAssertions; }
virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; }
private:
ConfigData m_data;

View File

@ -30,6 +30,7 @@
#include "catch_text.hpp"
#include "catch_message.hpp"
#include "catch_legacy_reporter_adapter.hpp"
#include "catch_timer.hpp"
#include "../reporters/catch_reporter_basic.hpp"
#include "../reporters/catch_reporter_xml.hpp"
@ -57,7 +58,6 @@ namespace Catch {
TestCaseStats::~TestCaseStats() {}
TestGroupStats::~TestGroupStats() {}
TestRunStats::~TestRunStats() {}
ThreadedSectionInfo::~ThreadedSectionInfo() {}
TestGroupNode::~TestGroupNode() {}
TestRunNode::~TestRunNode() {}

View File

@ -30,7 +30,7 @@ namespace Catch {
virtual void assertionEnded( AssertionResult const& result ) = 0;
virtual bool sectionStarted( SectionInfo const& sectionInfo,
Counts& assertions ) = 0;
virtual void sectionEnded( SectionInfo const& name, Counts const& assertions ) = 0;
virtual void sectionEnded( SectionInfo const& name, Counts const& assertions, double _durationInSeconds ) = 0;
virtual void pushScopedMessage( MessageInfo const& message ) = 0;
virtual void popScopedMessage( MessageInfo const& message ) = 0;

View File

@ -15,6 +15,23 @@
namespace Catch {
struct Verbosity { enum Level {
NoOutput = 0,
Quiet,
Normal
}; };
struct WarnAbout { enum What {
Nothing = 0x00,
NoAssertions = 0x01
}; };
struct ShowDurations { enum OrNot {
DefaultForReporter,
Always,
Never
}; };
struct IConfig : IShared {
virtual ~IConfig();
@ -26,6 +43,7 @@ namespace Catch {
virtual bool shouldDebugBreak() const = 0;
virtual bool warnAboutMissingAssertions() const = 0;
virtual int abortAfter() const = 0;
virtual ShowDurations::OrNot showDurations() const = 0;
};
}

View File

@ -46,6 +46,20 @@ namespace Catch
bool shouldRedirectStdOut;
};
template<typename T>
struct Node : SharedImpl<> {
Node( T const& _value, Node* _parent = NULL )
: value( _value ),
parent( _parent )
{}
virtual ~Node() {}
T value;
std::vector<Ptr<Node> > children;
Node* parent;
};
struct TestRunInfo {
TestRunInfo( std::string const& _name ) : name( _name ) {}
std::string name;
@ -78,17 +92,6 @@ namespace Catch
SourceLineInfo lineInfo;
};
struct ThreadedSectionInfo : SectionInfo, SharedImpl<> {
ThreadedSectionInfo( SectionInfo const& _sectionInfo, ThreadedSectionInfo* _parent = NULL )
: SectionInfo( _sectionInfo ),
parent( _parent )
{}
virtual ~ThreadedSectionInfo();
std::vector<Ptr<ThreadedSectionInfo> > children;
ThreadedSectionInfo* parent;
};
struct AssertionStats {
AssertionStats( AssertionResult const& _assertionResult,
std::vector<MessageInfo> const& _infoMessages,
@ -117,15 +120,18 @@ namespace Catch
struct SectionStats {
SectionStats( SectionInfo const& _sectionInfo,
Counts const& _assertions,
double _durationInSeconds,
bool _missingAssertions )
: sectionInfo( _sectionInfo ),
assertions( _assertions ),
durationInSeconds( _durationInSeconds ),
missingAssertions( _missingAssertions )
{}
virtual ~SectionStats();
SectionInfo sectionInfo;
Counts assertions;
double durationInSeconds;
bool missingAssertions;
};
@ -189,6 +195,7 @@ namespace Catch
bool aborting;
};
struct IStreamingReporter : IShared {
virtual ~IStreamingReporter();
@ -236,7 +243,7 @@ namespace Catch
unusedTestCaseInfo = _testInfo;
}
virtual void sectionStarting( SectionInfo const& _sectionInfo ) {
Ptr<ThreadedSectionInfo> sectionInfo = new ThreadedSectionInfo( _sectionInfo );
Ptr<Node<SectionInfo> > sectionInfo = new Node<SectionInfo>( _sectionInfo );
if( !currentSectionInfo ) {
currentSectionInfo = sectionInfo;
m_rootSections.push_back( currentSectionInfo );
@ -268,11 +275,11 @@ namespace Catch
Option<TestRunInfo> testRunInfo;
Option<GroupInfo> unusedGroupInfo;
Option<TestCaseInfo> unusedTestCaseInfo;
Ptr<ThreadedSectionInfo> currentSectionInfo;
Ptr<Node<SectionInfo> > currentSectionInfo;
std::ostream& stream;
// !TBD: This should really go in the TestCaseStats class
std::vector<Ptr<ThreadedSectionInfo> > m_rootSections;
std::vector<Ptr<Node<SectionInfo> > > m_rootSections;
};
struct TestGroupNode : TestGroupStats {

View File

@ -18,6 +18,7 @@
#include "catch_totals.hpp"
#include "catch_test_spec.h"
#include "catch_test_case_tracker.hpp"
#include "catch_timer.h"
#include <set>
#include <string>
@ -194,9 +195,9 @@ namespace Catch {
return true;
}
virtual void sectionEnded( SectionInfo const& info, Counts const& prevAssertions ) {
virtual void sectionEnded( SectionInfo const& info, Counts const& prevAssertions, double _durationInSeconds ) {
if( std::uncaught_exception() ) {
m_unfinishedSections.push_back( UnfinishedSections( info, prevAssertions ) );
m_unfinishedSections.push_back( UnfinishedSections( info, prevAssertions, _durationInSeconds ) );
return;
}
@ -205,7 +206,7 @@ namespace Catch {
m_testCaseTracker->leaveSection();
m_reporter->sectionEnded( SectionStats( info, assertions, missingAssertions ) );
m_reporter->sectionEnded( SectionStats( info, assertions, _durationInSeconds, missingAssertions ) );
m_messages.clear();
}
@ -260,10 +261,13 @@ namespace Catch {
SectionInfo testCaseSection( testCaseInfo.name, testCaseInfo.description, testCaseInfo.lineInfo );
m_reporter->sectionStarting( testCaseSection );
Counts prevAssertions = m_totals.assertions;
double duration = 0;
try {
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
TestCaseTracker::Guard guard( *m_testCaseTracker );
Timer timer;
timer.start();
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
StreamRedirect coutRedir( std::cout, redirectedCout );
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
@ -272,6 +276,7 @@ namespace Catch {
else {
m_activeTestCase->invoke();
}
duration = timer.getElapsedSeconds();
}
catch( TestFailureException& ) {
// This just means the test was aborted due to failure
@ -287,25 +292,26 @@ namespace Catch {
itEnd = m_unfinishedSections.end();
it != itEnd;
++it )
sectionEnded( it->info, it->prevAssertions );
sectionEnded( it->info, it->prevAssertions, it->durationInSeconds );
m_unfinishedSections.clear();
m_messages.clear();
Counts assertions = m_totals.assertions - prevAssertions;
bool missingAssertions = testForMissingAssertions( assertions );
SectionStats testCaseSectionStats( testCaseSection, assertions, missingAssertions );
SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions );
m_reporter->sectionEnded( testCaseSectionStats );
}
private:
struct UnfinishedSections {
UnfinishedSections( SectionInfo const& _info, Counts const& _prevAssertions )
: info( _info ), prevAssertions( _prevAssertions )
UnfinishedSections( SectionInfo const& _info, Counts const& _prevAssertions, double _durationInSeconds )
: info( _info ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds )
{}
SectionInfo info;
Counts prevAssertions;
double durationInSeconds;
};
TestRunInfo m_runInfo;

View File

@ -11,6 +11,7 @@
#include "catch_capture.hpp"
#include "catch_totals.hpp"
#include "catch_compiler_capabilities.h"
#include "catch_timer.h"
#include <string>
@ -23,11 +24,13 @@ namespace Catch {
std::string const& description = "" )
: m_info( name, description, lineInfo ),
m_sectionIncluded( getCurrentContext().getResultCapture().sectionStarted( m_info, m_assertions ) )
{}
{
m_timer.start();
}
~Section() {
if( m_sectionIncluded )
getCurrentContext().getResultCapture().sectionEnded( m_info, m_assertions );
getCurrentContext().getResultCapture().sectionEnded( m_info, m_assertions, m_timer.getElapsedSeconds() );
}
// This indicates whether the section should be executed or not
@ -41,6 +44,7 @@ namespace Catch {
std::string m_name;
Counts m_assertions;
bool m_sectionIncluded;
Timer m_timer;
};
} // end namespace Catch

View File

@ -0,0 +1,33 @@
/*
* Created by Phil on 05/08/2013.
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_CATCH_TIMER_H_INCLUDED
#define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED
#ifdef WIN32
typedef unsigned long long uint64_t;
#else
#include <stdint.h>
#endif
namespace Catch {
class Timer {
public:
Timer() : m_ticks( 0 ) {}
void start();
unsigned int getElapsedNanoseconds() const;
unsigned int getElapsedMilliseconds() const;
double getElapsedSeconds() const;
private:
uint64_t m_ticks;
};
} // namespace Catch
#endif // TWOBLUECUBES_CATCH_TIMER_H_INCLUDED

View File

@ -0,0 +1,62 @@
/*
* Created by Phil on 05/08/2013.
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include "catch_timer.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++11-long-long"
#endif
#ifdef WIN32
#include <windows.h>
#else
#include <sys/time.h>
#endif
namespace Catch {
namespace {
#ifdef WIN32
uint64_t getCurrentTicks() {
static uint64_t hz=0, hzo=0;
if (!hz) {
QueryPerformanceFrequency((LARGE_INTEGER*)&hz);
QueryPerformanceCounter((LARGE_INTEGER*)&hzo);
}
uint64_t t;
QueryPerformanceCounter((LARGE_INTEGER*)&t);
return ((t-hzo)*1000000)/hz;
}
#else
uint64_t getCurrentTicks() {
timeval t;
gettimeofday(&t,NULL);
return (uint64_t)t.tv_sec * 1000000ull + (uint64_t)t.tv_usec;
}
#endif
}
void Timer::start() {
m_ticks = getCurrentTicks();
}
unsigned int Timer::getElapsedNanoseconds() const {
return (unsigned int)(getCurrentTicks() - m_ticks);
}
unsigned int Timer::getElapsedMilliseconds() const {
return (unsigned int)((getCurrentTicks() - m_ticks)/1000);
}
double Timer::getElapsedSeconds() const {
return (getCurrentTicks() - m_ticks)/1000000.0;
}
} // namespace Catch
#ifdef __clang__
#pragma clang diagnostic pop
#endif

View File

@ -69,6 +69,8 @@ namespace Catch {
stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl;
}
m_headerPrinted = false;
if( m_config->showDurations() == ShowDurations::Always )
stream << "Completed in " << _sectionStats.durationInSeconds << "s" << std::endl;
StreamingReporterBase::sectionEnded( _sectionStats );
}
@ -263,20 +265,20 @@ namespace Catch {
assert( currentSectionInfo );
if( currentSectionInfo ) {
Colour colourGuard( Colour::Headers );
std::vector<ThreadedSectionInfo*> sections;
for( ThreadedSectionInfo* section = currentSectionInfo.get();
std::vector<Node<SectionInfo>*> sections;
for( Node<SectionInfo>* section = currentSectionInfo.get();
section;
section = section->parent )
sections.push_back( section );
// Sections
std::vector<ThreadedSectionInfo*>::const_reverse_iterator
std::vector<Node<SectionInfo>*>::const_reverse_iterator
it = sections.rbegin(), itEnd = sections.rend();
for( ++it; it != itEnd; ++it ) // Skip first section (test case)
printHeaderString( (*it)->name, 2 );
printHeaderString( (*it)->value.name, 2 );
}
SourceLineInfo lineInfo = currentSectionInfo
? currentSectionInfo->lineInfo
? currentSectionInfo->value.lineInfo
: unusedTestCaseInfo->lineInfo;
if( !lineInfo.empty() ){

View File

@ -82,7 +82,7 @@ namespace Catch {
return true;
}
virtual void StartTesting(){}
virtual void StartTesting() {}
virtual void StartGroup( const std::string& groupName ) {
if( groupName.empty() )
@ -189,7 +189,10 @@ namespace Catch {
xml.writeAttribute( "failures", it->m_failuresCount );
xml.writeAttribute( "tests", it->m_testsCount );
xml.writeAttribute( "hostname", "tbd" );
xml.writeAttribute( "time", "tbd" );
if( m_config.fullConfig()->showDurations() == ShowDurations::Never )
xml.writeAttribute( "time", it->m_timeInSeconds );
else
xml.writeAttribute( "time", "" );
xml.writeAttribute( "timestamp", "tbd" );
OutputTestCases( xml, *it );
@ -207,7 +210,10 @@ namespace Catch {
XmlWriter::ScopedElement e = xml.scopedElement( "testcase" );
xml.writeAttribute( "classname", it->m_className );
xml.writeAttribute( "name", it->m_name );
xml.writeAttribute( "time", "tbd" );
if( m_config.fullConfig()->showDurations() == ShowDurations::Never )
xml.writeAttribute( "time", "" );
else
xml.writeAttribute( "time", stats.m_timeInSeconds );
OutputTestResult( xml, *it );

View File

@ -670,6 +670,8 @@ MiscTests.cpp: FAILED:
explicitly with message:
to infinity and beyond
starting...
finished in 0.322593
Message from section one
Message from section two
Some information
@ -708,7 +710,7 @@ with expansion:
"first" == "second"
===============================================================================
121 test cases - 35 failed (737 assertions - 90 failed)
122 test cases - 35 failed (738 assertions - 90 failed)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -4316,6 +4318,19 @@ MiscTests.cpp: FAILED:
explicitly with message:
to infinity and beyond
starting...
finished in 0.323247
-------------------------------------------------------------------------------
Timer
-------------------------------------------------------------------------------
MiscTests.cpp
...............................................................................
MiscTests.cpp:
PASSED:
with message:
yay
-------------------------------------------------------------------------------
selftest/main
selftest/expected result
@ -7169,34 +7184,34 @@ with expansion:
true
===============================================================================
121 test cases - 50 failed (756 assertions - 109 failed)
122 test cases - 50 failed (757 assertions - 109 failed)
No test cases matched '~dummy 4'
No tests ran
<testsuites>
<testsuite name="~dummy" errors="10" failures="81" tests="756" hostname="tbd" time="tbd" timestamp="tbd">
<testcase classname="global" name="./succeeding/Approx/simple" time="tbd"/>
<testcase classname="global" name="./succeeding/Approx/epsilon" time="tbd"/>
<testcase classname="global" name="./succeeding/Approx/float" time="tbd"/>
<testcase classname="global" name="./succeeding/Approx/int" time="tbd"/>
<testcase classname="global" name="./succeeding/Approx/mixed" time="tbd"/>
<testcase classname="global" name="./succeeding/Approx/custom" time="tbd"/>
<testcase classname="global" name="Approximate PI" time="tbd"/>
<testcase classname="TestClass" name="./succeeding/TestClass/succeedingCase" time="tbd"/>
<testcase classname="TestClass" name="./failing/TestClass/failingCase" time="tbd">
<testsuite name="~dummy" errors="10" failures="81" tests="757" hostname="tbd" time="" timestamp="tbd">
<testcase classname="global" name="./succeeding/Approx/simple" time="0"/>
<testcase classname="global" name="./succeeding/Approx/epsilon" time="0"/>
<testcase classname="global" name="./succeeding/Approx/float" time="0"/>
<testcase classname="global" name="./succeeding/Approx/int" time="0"/>
<testcase classname="global" name="./succeeding/Approx/mixed" time="0"/>
<testcase classname="global" name="./succeeding/Approx/custom" time="0"/>
<testcase classname="global" name="Approximate PI" time="0"/>
<testcase classname="TestClass" name="./succeeding/TestClass/succeedingCase" time="0"/>
<testcase classname="TestClass" name="./failing/TestClass/failingCase" time="0">
<failure message="&quot;hello&quot; == &quot;world&quot;" type="REQUIRE">
ClassTests.cpp
</failure>
</testcase>
<testcase classname="Fixture" name="./succeeding/Fixture/succeedingCase" time="tbd"/>
<testcase classname="Fixture" name="./failing/Fixture/failingCase" time="tbd">
<testcase classname="Fixture" name="./succeeding/Fixture/succeedingCase" time="0"/>
<testcase classname="Fixture" name="./failing/Fixture/failingCase" time="0">
<failure message="1 == 2" type="REQUIRE">
ClassTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/conditions/equality" time="tbd"/>
<testcase classname="global" name="./failing/conditions/equality" time="tbd">
<testcase classname="global" name="./succeeding/conditions/equality" time="0"/>
<testcase classname="global" name="./failing/conditions/equality" time="0">
<failure message="7 == 6" type="CHECK">
ConditionTests.cpp
</failure>
@ -7237,8 +7252,8 @@ ConditionTests.cpp
ConditionTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/conditions/inequality" time="tbd"/>
<testcase classname="global" name="./failing/conditions/inequality" time="tbd">
<testcase classname="global" name="./succeeding/conditions/inequality" time="0"/>
<testcase classname="global" name="./failing/conditions/inequality" time="0">
<failure message="7 != 7" type="CHECK">
ConditionTests.cpp
</failure>
@ -7255,8 +7270,8 @@ ConditionTests.cpp
ConditionTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/conditions/ordered" time="tbd"/>
<testcase classname="global" name="./failing/conditions/ordered" time="tbd">
<testcase classname="global" name="./succeeding/conditions/ordered" time="0"/>
<testcase classname="global" name="./failing/conditions/ordered" time="0">
<failure message="7 > 7" type="CHECK">
ConditionTests.cpp
</failure>
@ -7315,14 +7330,14 @@ ConditionTests.cpp
ConditionTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/conditions/int literals" time="tbd"/>
<testcase classname="global" name="./succeeding/conditions//long_to_unsigned_x" time="tbd"/>
<testcase classname="global" name="./succeeding/conditions/const ints to int literal" time="tbd"/>
<testcase classname="global" name="./succeeding/conditions/negative ints" time="tbd"/>
<testcase classname="global" name="./succeeding/conditions/computed ints" time="tbd"/>
<testcase classname="global" name="./succeeding/conditions/ptr" time="tbd"/>
<testcase classname="global" name="./succeeding/conditions/not" time="tbd"/>
<testcase classname="global" name="./failing/conditions/not" time="tbd">
<testcase classname="global" name="./succeeding/conditions/int literals" time="0"/>
<testcase classname="global" name="./succeeding/conditions//long_to_unsigned_x" time="0"/>
<testcase classname="global" name="./succeeding/conditions/const ints to int literal" time="0"/>
<testcase classname="global" name="./succeeding/conditions/negative ints" time="0"/>
<testcase classname="global" name="./succeeding/conditions/computed ints" time="0"/>
<testcase classname="global" name="./succeeding/conditions/ptr" time="0"/>
<testcase classname="global" name="./succeeding/conditions/not" time="0"/>
<testcase classname="global" name="./failing/conditions/not" time="0">
<failure message="false != false" type="CHECK">
ConditionTests.cpp
</failure>
@ -7348,8 +7363,8 @@ ConditionTests.cpp
ConditionTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/exceptions/explicit" time="tbd"/>
<testcase classname="global" name="./failing/exceptions/explicit" time="tbd">
<testcase classname="global" name="./succeeding/exceptions/explicit" time="0"/>
<testcase classname="global" name="./failing/exceptions/explicit" time="0">
<error message="thisThrows()" type="CHECK_THROWS_AS">
ExceptionTests.cpp
</error>
@ -7360,51 +7375,51 @@ ExceptionTests.cpp
ExceptionTests.cpp
</error>
</testcase>
<testcase classname="global" name="./failing/exceptions/implicit" time="tbd">
<testcase classname="global" name="./failing/exceptions/implicit" time="0">
<error type="TEST_CASE">
ExceptionTests.cpp
</error>
</testcase>
<testcase classname="global" name="./failing/exceptions/implicit/2" time="tbd">
<testcase classname="global" name="./failing/exceptions/implicit/2" time="0">
<error message="{Unknown expression after the reported line}">
ExceptionTests.cpp
</error>
</testcase>
<testcase classname="global" name="./failing/exceptions/implicit/3" time="tbd">
<testcase classname="global" name="./failing/exceptions/implicit/3" time="0">
<error type="TEST_CASE">
ExceptionTests.cpp
</error>
</testcase>
<testcase classname="global" name="./failing/exceptions/implicit/4" time="tbd">
<testcase classname="global" name="./failing/exceptions/implicit/4" time="0">
<error message="thisThrows() == 0" type="CHECK">
ExceptionTests.cpp
</error>
</testcase>
<testcase classname="global" name="./succeeding/exceptions/implicit" time="tbd"/>
<testcase classname="global" name="./failing/exceptions/custom" time="tbd">
<testcase classname="global" name="./succeeding/exceptions/implicit" time="0"/>
<testcase classname="global" name="./failing/exceptions/custom" time="0">
<error type="TEST_CASE">
ExceptionTests.cpp
</error>
</testcase>
<testcase classname="global" name="./failing/exceptions/custom/nothrow" time="tbd">
<testcase classname="global" name="./failing/exceptions/custom/nothrow" time="0">
<error message="throwCustom()" type="REQUIRE_NOTHROW">
ExceptionTests.cpp
</error>
</testcase>
<testcase classname="global" name="./failing/exceptions/custom/throw" time="tbd">
<testcase classname="global" name="./failing/exceptions/custom/throw" time="0">
<error message="throwCustom()" type="REQUIRE_THROWS_AS">
ExceptionTests.cpp
</error>
</testcase>
<testcase classname="global" name="./failing/exceptions/custom/double" time="tbd">
<testcase classname="global" name="./failing/exceptions/custom/double" time="0">
<error type="TEST_CASE">
ExceptionTests.cpp
</error>
</testcase>
<testcase classname="global" name="./succeeding/exceptions/notimplemented" time="tbd"/>
<testcase classname="global" name="./succeeding/generators/1" time="tbd"/>
<testcase classname="global" name="./succeeding/generators/2" time="tbd"/>
<testcase classname="global" name="./succeeding/message" time="tbd">
<testcase classname="global" name="./succeeding/exceptions/notimplemented" time="0"/>
<testcase classname="global" name="./succeeding/generators/1" time="0"/>
<testcase classname="global" name="./succeeding/generators/2" time="0"/>
<testcase classname="global" name="./succeeding/message" time="0">
<info type="INFO">
MessageTests.cpp
</info>
@ -7412,8 +7427,8 @@ MessageTests.cpp
MessageTests.cpp
</warning>
</testcase>
<testcase classname="global" name="./succeeding/succeed" time="tbd"/>
<testcase classname="global" name="./failing/message/info/1" time="tbd">
<testcase classname="global" name="./succeeding/succeed" time="0"/>
<testcase classname="global" name="./failing/message/info/1" time="0">
<info type="INFO">
MessageTests.cpp
</info>
@ -7424,7 +7439,7 @@ MessageTests.cpp
MessageTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./mixed/message/info/2" time="tbd">
<testcase classname="global" name="./mixed/message/info/2" time="0">
<info type="INFO">
MessageTests.cpp
</info>
@ -7438,12 +7453,12 @@ MessageTests.cpp
MessageTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./failing/message/fail" time="tbd">
<testcase classname="global" name="./failing/message/fail" time="0">
<failure type="FAIL">
MessageTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./failing/message/sections" time="tbd">
<testcase classname="global" name="./failing/message/sections" time="0">
<failure type="FAIL">
MessageTests.cpp
</failure>
@ -7451,13 +7466,13 @@ MessageTests.cpp
MessageTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/message/sections/stdout" time="tbd">
<testcase classname="global" name="./succeeding/message/sections/stdout" time="0">
<system-out>
Message from section one
Message from section two
</system-out>
</testcase>
<testcase classname="global" name="./mixed/message/scoped" time="tbd">
<testcase classname="global" name="./mixed/message/scoped" time="0">
<info type="INFO">
MessageTests.cpp
</info>
@ -7468,31 +7483,31 @@ MessageTests.cpp
MessageTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/nofail" time="tbd">
<testcase classname="global" name="./succeeding/nofail" time="0">
<failure message="1 == 2" type="CHECK_NOFAIL">
MessageTests.cpp
</failure>
</testcase>
<testcase classname="global" name="just info" time="tbd"/>
<testcase classname="global" name="just failure" time="tbd">
<testcase classname="global" name="just info" time="0"/>
<testcase classname="global" name="just failure" time="0">
<failure type="FAIL">
MessageTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/Misc/Sections" time="tbd"/>
<testcase classname="global" name="./succeeding/Misc/Sections/nested" time="tbd"/>
<testcase classname="global" name="./mixed/Misc/Sections/nested2" time="tbd">
<testcase classname="global" name="./succeeding/Misc/Sections" time="0"/>
<testcase classname="global" name="./succeeding/Misc/Sections/nested" time="0"/>
<testcase classname="global" name="./mixed/Misc/Sections/nested2" time="0">
<failure message="1 == 2" type="REQUIRE">
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./Sections/nested/a/b" time="tbd"/>
<testcase classname="global" name="./mixed/Misc/Sections/loops" time="tbd">
<testcase classname="global" name="./Sections/nested/a/b" time="0"/>
<testcase classname="global" name="./mixed/Misc/Sections/loops" time="0">
<failure message="0 > 1" type="CHECK">
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./mixed/Misc/loops" time="tbd">
<testcase classname="global" name="./mixed/Misc/loops" time="0">
<info type="INFO">
MiscTests.cpp
</info>
@ -7530,7 +7545,7 @@ MiscTests.cpp
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/Misc/stdout,stderr" time="tbd">
<testcase classname="global" name="./succeeding/Misc/stdout,stderr" time="0">
<system-out>
Some information
</system-out>
@ -7538,8 +7553,8 @@ Some information
An error
</system-err>
</testcase>
<testcase classname="global" name="./succeeding/Misc/null strings" time="tbd"/>
<testcase classname="global" name="./failing/info" time="tbd">
<testcase classname="global" name="./succeeding/Misc/null strings" time="0"/>
<testcase classname="global" name="./failing/info" time="0">
<info type="INFO">
MiscTests.cpp
</info>
@ -7550,8 +7565,8 @@ MiscTests.cpp
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/checkedif" time="tbd"/>
<testcase classname="global" name="./failing/checkedif" time="tbd">
<testcase classname="global" name="./succeeding/checkedif" time="0"/>
<testcase classname="global" name="./failing/checkedif" time="0">
<failure message="false" type="CHECKED_IF">
MiscTests.cpp
</failure>
@ -7559,8 +7574,8 @@ MiscTests.cpp
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/checkedelse" time="tbd"/>
<testcase classname="global" name="./failing/checkedelse" time="tbd">
<testcase classname="global" name="./succeeding/checkedelse" time="0"/>
<testcase classname="global" name="./failing/checkedelse" time="0">
<failure message="false" type="CHECKED_ELSE">
MiscTests.cpp
</failure>
@ -7568,8 +7583,8 @@ MiscTests.cpp
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./misc/xmlentitycheck" time="tbd"/>
<testcase classname="global" name="./manual/onechar" time="tbd">
<testcase classname="global" name="./misc/xmlentitycheck" time="0"/>
<testcase classname="global" name="./manual/onechar" time="0">
<info type="INFO">
MiscTests.cpp
</info>
@ -7577,43 +7592,43 @@ MiscTests.cpp
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/atomic if" time="tbd"/>
<testcase classname="global" name="./succeeding/matchers" time="tbd"/>
<testcase classname="global" name="./failing/matchers/Contains" time="tbd">
<testcase classname="global" name="./succeeding/atomic if" time="0"/>
<testcase classname="global" name="./succeeding/matchers" time="0"/>
<testcase classname="global" name="./failing/matchers/Contains" time="0">
<failure message="&quot;this string contains 'abc' as a substring&quot; contains: &quot;not there&quot;" type="CHECK_THAT">
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./failing/matchers/StartsWith" time="tbd">
<testcase classname="global" name="./failing/matchers/StartsWith" time="0">
<failure message="&quot;this string contains 'abc' as a substring&quot; starts with: &quot;string&quot;" type="CHECK_THAT">
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./failing/matchers/EndsWith" time="tbd">
<testcase classname="global" name="./failing/matchers/EndsWith" time="0">
<failure message="&quot;this string contains 'abc' as a substring&quot; ends with: &quot;this&quot;" type="CHECK_THAT">
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./failing/matchers/Equals" time="tbd">
<testcase classname="global" name="./failing/matchers/Equals" time="0">
<failure message="&quot;this string contains 'abc' as a substring&quot; equals: &quot;something else&quot;" type="CHECK_THAT">
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="string" time="tbd"/>
<testcase classname="global" name="./succeeding/matchers/AllOf" time="tbd"/>
<testcase classname="global" name="./succeeding/matchers/AnyOf" time="tbd"/>
<testcase classname="global" name="./succeeding/matchers/Equals" time="tbd"/>
<testcase classname="global" name="Factorials are computed" time="tbd"/>
<testcase classname="global" name="empty" time="tbd"/>
<testcase classname="global" name="Nice descriptive name" time="tbd">
<testcase classname="global" name="string" time="0"/>
<testcase classname="global" name="./succeeding/matchers/AllOf" time="0"/>
<testcase classname="global" name="./succeeding/matchers/AnyOf" time="0"/>
<testcase classname="global" name="./succeeding/matchers/Equals" time="0"/>
<testcase classname="global" name="Factorials are computed" time="0"/>
<testcase classname="global" name="empty" time="0"/>
<testcase classname="global" name="Nice descriptive name" time="0">
<warning type="WARN">
MiscTests.cpp
</warning>
</testcase>
<testcase classname="global" name="first tag" time="tbd"/>
<testcase classname="global" name="second tag" time="tbd"/>
<testcase classname="global" name="vectors can be sized and resized" time="tbd"/>
<testcase classname="global" name="./failing/CatchSectionInfiniteLoop" time="tbd">
<testcase classname="global" name="first tag" time="0"/>
<testcase classname="global" name="second tag" time="0"/>
<testcase classname="global" name="vectors can be sized and resized" time="0"/>
<testcase classname="global" name="./failing/CatchSectionInfiniteLoop" time="0">
<failure type="FAIL">
MiscTests.cpp
</failure>
@ -7624,7 +7639,13 @@ MiscTests.cpp
MiscTests.cpp
</failure>
</testcase>
<testcase classname="global" name="selftest/main" time="tbd">
<testcase classname="global" name="Timer" time="0">
<system-out>
starting...
finished in 0.322247
</system-out>
</testcase>
<testcase classname="global" name="selftest/main" time="0">
<system-out>
Message from section one
Message from section two
@ -7638,33 +7659,33 @@ An error
An error
</system-err>
</testcase>
<testcase classname="global" name="meta/Misc/Sections" time="tbd"/>
<testcase classname="global" name="Process can be configured on command line" time="tbd"/>
<testcase classname="global" name="selftest/test filter" time="tbd"/>
<testcase classname="global" name="selftest/test filters" time="tbd"/>
<testcase classname="global" name="selftest/filter/prefix wildcard" time="tbd"/>
<testcase classname="global" name="selftest/filter/wildcard at both ends" time="tbd"/>
<testcase classname="global" name="selftest/tags" time="tbd"/>
<testcase classname="global" name="Long strings can be wrapped" time="tbd"/>
<testcase classname="global" name="Strings can be rendered with colour" time="tbd">
<testcase classname="global" name="meta/Misc/Sections" time="0"/>
<testcase classname="global" name="Process can be configured on command line" time="0"/>
<testcase classname="global" name="selftest/test filter" time="0"/>
<testcase classname="global" name="selftest/test filters" time="0"/>
<testcase classname="global" name="selftest/filter/prefix wildcard" time="0"/>
<testcase classname="global" name="selftest/filter/wildcard at both ends" time="0"/>
<testcase classname="global" name="selftest/tags" time="0"/>
<testcase classname="global" name="Long strings can be wrapped" time="0"/>
<testcase classname="global" name="Strings can be rendered with colour" time="0">
<system-out>
hello
hello
</system-out>
</testcase>
<testcase classname="global" name="Text can be formatted using the Text class" time="tbd"/>
<testcase classname="global" name="./succeeding/Tricky/std::pair" time="tbd"/>
<testcase classname="global" name="./inprogress/failing/Tricky/trailing expression" time="tbd">
<testcase classname="global" name="Text can be formatted using the Text class" time="0"/>
<testcase classname="global" name="./succeeding/Tricky/std::pair" time="0"/>
<testcase classname="global" name="./inprogress/failing/Tricky/trailing expression" time="0">
<warning type="WARN">
TrickyTests.cpp
</warning>
</testcase>
<testcase classname="global" name="./inprogress/failing/Tricky/compound lhs" time="tbd">
<testcase classname="global" name="./inprogress/failing/Tricky/compound lhs" time="0">
<warning type="WARN">
TrickyTests.cpp
</warning>
</testcase>
<testcase classname="global" name="./failing/Tricky/non streamable type" time="tbd">
<testcase classname="global" name="./failing/Tricky/non streamable type" time="0">
<failure message="0x<hex digits> == 0x<hex digits>" type="CHECK">
TrickyTests.cpp
</failure>
@ -7672,34 +7693,34 @@ TrickyTests.cpp
TrickyTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./failing/string literals" time="tbd">
<testcase classname="global" name="./failing/string literals" time="0">
<failure message="&quot;first&quot; == &quot;second&quot;" type="REQUIRE">
TrickyTests.cpp
</failure>
</testcase>
<testcase classname="global" name="./succeeding/side-effects" time="tbd"/>
<testcase classname="global" name="./succeeding/koenig" time="tbd"/>
<testcase classname="global" name="./succeeding/non-const==" time="tbd"/>
<testcase classname="global" name="./succeeding/enum/bits" time="tbd"/>
<testcase classname="global" name="./succeeding/boolean member" time="tbd"/>
<testcase classname="global" name="./succeeding/unimplemented static bool" time="tbd"/>
<testcase classname="global" name="./succeeding/SafeBool" time="tbd"/>
<testcase classname="global" name="Assertions then sections" time="tbd"/>
<testcase classname="global" name="non streamable - with conv. op" time="tbd"/>
<testcase classname="global" name="Comparing function pointers" time="tbd"/>
<testcase classname="global" name="pointer to class" time="tbd"/>
<testcase classname="global" name="X/level/0/a" time="tbd"/>
<testcase classname="global" name="X/level/0/b" time="tbd"/>
<testcase classname="global" name="X/level/1/a" time="tbd"/>
<testcase classname="global" name="X/level/1/b" time="tbd"/>
<testcase classname="global" name="Anonymous test case 1" time="tbd"/>
<testcase classname="global" name="Test case with one argument" time="tbd"/>
<testcase classname="global" name="Variadic macros" time="tbd"/>
<testcase classname="global" name="Scenario: Do that thing with the thing" time="tbd"/>
<testcase classname="global" name="Scenario: Vector resizing affects size and capacity" time="tbd"/>
<testcase classname="global" name="Scenario: This is a really long scenario name to see how the list command deals with wrapping" time="tbd"/>
<testcase classname="global" name="cmdline" time="tbd"/>
<testcase classname="global" name="section tracking" time="tbd"/>
<testcase classname="global" name="./succeeding/side-effects" time="0"/>
<testcase classname="global" name="./succeeding/koenig" time="0"/>
<testcase classname="global" name="./succeeding/non-const==" time="0"/>
<testcase classname="global" name="./succeeding/enum/bits" time="0"/>
<testcase classname="global" name="./succeeding/boolean member" time="0"/>
<testcase classname="global" name="./succeeding/unimplemented static bool" time="0"/>
<testcase classname="global" name="./succeeding/SafeBool" time="0"/>
<testcase classname="global" name="Assertions then sections" time="0"/>
<testcase classname="global" name="non streamable - with conv. op" time="0"/>
<testcase classname="global" name="Comparing function pointers" time="0"/>
<testcase classname="global" name="pointer to class" time="0"/>
<testcase classname="global" name="X/level/0/a" time="0"/>
<testcase classname="global" name="X/level/0/b" time="0"/>
<testcase classname="global" name="X/level/1/a" time="0"/>
<testcase classname="global" name="X/level/1/b" time="0"/>
<testcase classname="global" name="Anonymous test case 1" time="0"/>
<testcase classname="global" name="Test case with one argument" time="0"/>
<testcase classname="global" name="Variadic macros" time="0"/>
<testcase classname="global" name="Scenario: Do that thing with the thing" time="0"/>
<testcase classname="global" name="Scenario: Vector resizing affects size and capacity" time="0"/>
<testcase classname="global" name="Scenario: This is a really long scenario name to see how the list command deals with wrapping" time="0"/>
<testcase classname="global" name="cmdline" time="0"/>
<testcase classname="global" name="section tracking" time="0"/>
</testsuite>
<system-out>
Message from section one
@ -7707,6 +7728,9 @@ Message from section two
Some information
starting...
finished in 0.322247
Message from section one
Message from section two
Some information
@ -11414,6 +11438,9 @@ An error
</Failure>
<OverallResult success="false"/>
</TestCase>
<TestCase name="Timer">
<OverallResult success="true"/>
</TestCase>
<TestCase name="selftest/main">
<Section name="selftest/expected result" description="Tests do what they claim">
<OverallResults successes="0" failures="0"/>
@ -14069,7 +14096,7 @@ there&quot;
</Section>
<OverallResult success="true"/>
</TestCase>
<OverallResults successes="647" failures="109"/>
<OverallResults successes="648" failures="109"/>
</Group>
<OverallResults successes="647" failures="109"/>
<OverallResults successes="648" failures="109"/>
</Catch>

View File

@ -341,3 +341,26 @@ TEST_CASE("./failing/CatchSectionInfiniteLoop", "")
FAIL("to infinity and beyond");
}
#include "internal/catch_timer.h"
TEST_CASE( "Timer", "[work-in-progress]" )
{
Catch::Timer t;
t.start();
std::cout << "starting..." << std::endl;
double d = 0;
for( int i = 0; i < 100000; ++i )
for( int j = 0; j < 1000; ++j )
d += (double)i*(double)j;
double duration = t.getElapsedSeconds();
std::cout << "finished in " << duration << std::endl;
SUCCEED("yay");
}

View File

@ -359,6 +359,10 @@
RelativePath="..\..\..\SelfTest\ClassTests.cpp"
>
</File>
<File
RelativePath="..\..\..\SelfTest\CmdLineTests.cpp"
>
</File>
<File
RelativePath="..\..\..\SelfTest\ConditionTests.cpp"
>
@ -379,6 +383,10 @@
RelativePath="..\..\..\SelfTest\MiscTests.cpp"
>
</File>
<File
RelativePath="..\..\..\SelfTest\SectionTrackerTests.cpp"
>
</File>
<File
RelativePath="..\..\..\SelfTest\TrickyTests.cpp"
>

View File

@ -57,6 +57,8 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
263FD06017AF8DF200988A20 /* catch_timer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_timer.hpp; sourceTree = "<group>"; };
263FD06117AF8DF200988A20 /* catch_timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_timer.h; sourceTree = "<group>"; };
266B06B616F3A60A004ED264 /* VariadicMacrosTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VariadicMacrosTests.cpp; path = ../../../SelfTest/VariadicMacrosTests.cpp; sourceTree = "<group>"; };
266E9AD117230ACF0061DAB2 /* catch_text.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_text.hpp; sourceTree = "<group>"; };
266E9AD417290E8E0061DAB2 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = "<group>"; };
@ -318,6 +320,7 @@
4AC91CB4155B9EBF00DC5117 /* impl */ = {
isa = PBXGroup;
children = (
263FD06017AF8DF200988A20 /* catch_timer.hpp */,
266E9AD117230ACF0061DAB2 /* catch_text.hpp */,
4A4B0F9C15CEFA8300AE2392 /* catch_impl.hpp */,
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */,
@ -423,6 +426,7 @@
26759472171C72A400A84BD1 /* catch_sfinae.hpp */,
26759473171C74C200A84BD1 /* catch_compiler_capabilities.h */,
26DACF2F17206D3400A21326 /* catch_text.h */,
263FD06117AF8DF200988A20 /* catch_timer.h */,
);
name = Infrastructure;
sourceTree = "<group>";