mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 23:06:10 +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.
|
* 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/interfaces/catch_interfaces_config.hpp>
|
||||||
#include <catch2/internal/catch_console_width.hpp>
|
#include <catch2/internal/catch_console_width.hpp>
|
||||||
#include <catch2/internal/catch_errno_guard.hpp>
|
#include <catch2/internal/catch_errno_guard.hpp>
|
||||||
#include <catch2/internal/catch_stream.hpp>
|
|
||||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@ -52,18 +53,26 @@ namespace Catch {
|
|||||||
return min >= 0 && duration >= min;
|
return min >= 0 && duration >= min;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string serializeFilters( std::vector<std::string> const& container ) {
|
std::string serializeFilters( std::vector<std::string> const& filters ) {
|
||||||
ReusableStringStream oss;
|
// We add a ' ' separator between each filter
|
||||||
bool first = true;
|
size_t serialized_size = filters.size() - 1;
|
||||||
for ( auto&& filter : container ) {
|
for (auto const& filter : filters) {
|
||||||
if ( !first )
|
serialized_size += filter.size();
|
||||||
oss << ' ';
|
|
||||||
else
|
|
||||||
first = false;
|
|
||||||
|
|
||||||
oss << filter;
|
|
||||||
}
|
}
|
||||||
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 ) {
|
std::ostream& operator<<( std::ostream& out, lineOfChars value ) {
|
||||||
|
@ -15,7 +15,7 @@ namespace Catch {
|
|||||||
//! Should the reporter show
|
//! Should the reporter show
|
||||||
bool shouldShowDuration( IConfig const& config, double duration );
|
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 {
|
struct lineOfChars {
|
||||||
char c;
|
char c;
|
||||||
|
Loading…
Reference in New Issue
Block a user