mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-05 21:59:54 +01:00
Refactor serializeFilters implementation
This commit is contained in:
parent
2a8e317cfb
commit
360b82620e
@ -10,13 +10,14 @@
|
||||
* of Catch2 has its own combined TU like this.
|
||||
*/
|
||||
|
||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||
#include <catch2/internal/catch_console_width.hpp>
|
||||
#include <catch2/internal/catch_errno_guard.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||
|
||||
#include <cfloat>
|
||||
#include <cstdio>
|
||||
#include <ostream>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -52,18 +53,26 @@ namespace Catch {
|
||||
return min >= 0 && duration >= min;
|
||||
}
|
||||
|
||||
std::string serializeFilters( std::vector<std::string> const& container ) {
|
||||
ReusableStringStream oss;
|
||||
bool first = true;
|
||||
for ( auto&& filter : container ) {
|
||||
if ( !first )
|
||||
oss << ' ';
|
||||
else
|
||||
first = false;
|
||||
|
||||
oss << filter;
|
||||
std::string serializeFilters( std::vector<std::string> const& filters ) {
|
||||
// We add a ' ' separator between each filter
|
||||
size_t serialized_size = filters.size() - 1;
|
||||
for (auto const& filter : filters) {
|
||||
serialized_size += filter.size();
|
||||
}
|
||||
return oss.str();
|
||||
|
||||
std::string serialized;
|
||||
serialized.reserve(serialized_size);
|
||||
bool first = true;
|
||||
|
||||
for (auto const& filter : filters) {
|
||||
if (!first) {
|
||||
serialized.push_back(' ');
|
||||
}
|
||||
first = false;
|
||||
serialized.append(filter);
|
||||
}
|
||||
|
||||
return serialized;
|
||||
}
|
||||
|
||||
std::ostream& operator<<( std::ostream& out, lineOfChars value ) {
|
||||
|
@ -15,7 +15,7 @@ namespace Catch {
|
||||
//! Should the reporter show
|
||||
bool shouldShowDuration( IConfig const& config, double duration );
|
||||
|
||||
std::string serializeFilters( std::vector<std::string> const& container );
|
||||
std::string serializeFilters( std::vector<std::string> const& filters );
|
||||
|
||||
struct lineOfChars {
|
||||
char c;
|
||||
|
Loading…
Reference in New Issue
Block a user