Skip to content

Commit

Permalink
Fix crash when running with --list-listeners and no registered listen…
Browse files Browse the repository at this point in the history
…ers.
  • Loading branch information
Sergio Losilla committed Jun 2, 2022
1 parent cca5923 commit 7ae9ffc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/catch2/reporters/catch_reporter_combined_tu.cpp
Expand Up @@ -154,6 +154,12 @@ namespace Catch {

void defaultListListeners( std::ostream& out,
std::vector<ListenerDescription> const& descriptions ) {
out << "Registered listeners:\n";

if(descriptions.empty()) {
return;
}

const auto maxNameLen =
std::max_element( descriptions.begin(),
descriptions.end(),
Expand All @@ -163,7 +169,6 @@ namespace Catch {
} )
->name.size();

out << "Registered listeners:\n";
for ( auto const& desc : descriptions ) {
out << TextFlow::Column( static_cast<std::string>( desc.name ) +
':' )
Expand Down

0 comments on commit 7ae9ffc

Please sign in to comment.