mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-16 18:52:25 +01:00
fixup! Report generator states for failed assertions
This commit is contained in:
parent
48a5431466
commit
33704524d8
@ -29,7 +29,7 @@ TEST_CASE("Generate random doubles across different ranges",
|
|||||||
// This will take r1 by reference and r2 by value.
|
// This will take r1 by reference and r2 by value.
|
||||||
// Note that there are no advantages for doing so in this example,
|
// Note that there are no advantages for doing so in this example,
|
||||||
// it is done only for expository purposes.
|
// it is done only for expository purposes.
|
||||||
auto number = Catch::Generators::generate( "custom capture generator", "custom definition", CATCH_INTERNAL_LINEINFO,
|
auto number = Catch::Generators::generate( "custom capture generator", "custom arguments description", CATCH_INTERNAL_LINEINFO,
|
||||||
[&r1, r2]{
|
[&r1, r2]{
|
||||||
using namespace Catch::Generators;
|
using namespace Catch::Generators;
|
||||||
return makeGenerators(take(50, random(std::get<0>(r1), std::get<1>(r2))));
|
return makeGenerators(take(50, random(std::get<0>(r1), std::get<1>(r2))));
|
||||||
|
@ -211,7 +211,7 @@ namespace Detail {
|
|||||||
// Note: The type after -> is weird, because VS2015 cannot parse
|
// Note: The type after -> is weird, because VS2015 cannot parse
|
||||||
// the expression used in the typedef inside, when it is in
|
// the expression used in the typedef inside, when it is in
|
||||||
// return type. Yeah.
|
// return type. Yeah.
|
||||||
auto generate( StringRef generatorName, StringRef definition, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) {
|
auto generate( StringRef generatorName, StringRef argumentsDescription, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) {
|
||||||
using UnderlyingType = typename decltype(generatorExpression())::type;
|
using UnderlyingType = typename decltype(generatorExpression())::type;
|
||||||
|
|
||||||
IGeneratorTracker& tracker = acquireGeneratorTracker( generatorName, lineInfo );
|
IGeneratorTracker& tracker = acquireGeneratorTracker( generatorName, lineInfo );
|
||||||
@ -220,7 +220,7 @@ namespace Detail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto const& generator = static_cast<IGenerator<UnderlyingType> const&>( *tracker.getGenerator() );
|
auto const& generator = static_cast<IGenerator<UnderlyingType> const&>( *tracker.getGenerator() );
|
||||||
getResultCapture().trackGeneratorState(GeneratorInfo(definition, lineInfo, generator.currentElementAsString()));
|
getResultCapture().trackGeneratorState(GeneratorInfo(generatorName, argumentsDescription, lineInfo, generator.currentElementAsString()));
|
||||||
return generator.get();
|
return generator.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,10 +10,12 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
GeneratorInfo::GeneratorInfo( StringRef _definition,
|
GeneratorInfo::GeneratorInfo( StringRef _name,
|
||||||
|
StringRef _arguments,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
StringRef _currentElement ):
|
StringRef _currentElement ):
|
||||||
definition( _definition ),
|
name( _name ),
|
||||||
|
arguments( _arguments ),
|
||||||
lineInfo( _lineInfo ),
|
lineInfo( _lineInfo ),
|
||||||
currentElement( _currentElement ) {}
|
currentElement( _currentElement ) {}
|
||||||
|
|
||||||
|
@ -15,16 +15,18 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct GeneratorInfo {
|
struct GeneratorInfo {
|
||||||
GeneratorInfo( StringRef _definition,
|
GeneratorInfo( StringRef _name,
|
||||||
|
StringRef _arguments,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
StringRef currentElement );
|
StringRef currentElement );
|
||||||
|
|
||||||
StringRef definition;
|
StringRef name;
|
||||||
|
StringRef arguments;
|
||||||
SourceLineInfo lineInfo;
|
SourceLineInfo lineInfo;
|
||||||
StringRef currentElement;
|
StringRef currentElement;
|
||||||
|
|
||||||
bool operator==( GeneratorInfo const& other ) const {
|
bool operator==( GeneratorInfo const& other ) const {
|
||||||
return definition == other.definition &&
|
return name == other.name && arguments == other.arguments &&
|
||||||
lineInfo == other.lineInfo &&
|
lineInfo == other.lineInfo &&
|
||||||
currentElement == other.currentElement;
|
currentElement == other.currentElement;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ private:
|
|||||||
for ( auto const& info : stats.generatorInfos ) {
|
for ( auto const& info : stats.generatorInfos ) {
|
||||||
stream << TextFlow::Column( "line:" ).indent( 2 )
|
stream << TextFlow::Column( "line:" ).indent( 2 )
|
||||||
<< info.lineInfo.line << ": "
|
<< info.lineInfo.line << ": "
|
||||||
<< "GENERATE(" << info.definition << ")\n"
|
<< "GENERATE(" << info.arguments << ")\n"
|
||||||
<< TextFlow::Column( "value: " ).indent( 2 )
|
<< TextFlow::Column( "value: " ).indent( 2 )
|
||||||
<< colourImpl->guardColour( Colour::GeneratorValue )
|
<< colourImpl->guardColour( Colour::GeneratorValue )
|
||||||
<< info.currentElement << '\n';
|
<< info.currentElement << '\n';
|
||||||
|
Loading…
Reference in New Issue
Block a user