2017-07-10 11:33:18 +02:00
|
|
|
/*
|
|
|
|
* Created by Phil on 27/11/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 "../internal/catch_interfaces_reporter.h"
|
|
|
|
#include "../internal/catch_errno_guard.h"
|
|
|
|
#include "catch_reporter_bases.hpp"
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <cfloat>
|
|
|
|
#include <cstdio>
|
2018-04-18 14:59:10 +02:00
|
|
|
#include <cassert>
|
2017-07-10 11:33:18 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace Catch {
|
2017-07-25 17:16:28 +02:00
|
|
|
void prepareExpandedExpression(AssertionResult& result) {
|
2017-08-09 10:08:33 +02:00
|
|
|
result.getExpandedExpression();
|
2017-07-25 17:16:28 +02:00
|
|
|
}
|
2017-07-10 11:33:18 +02:00
|
|
|
|
|
|
|
// Because formatting using c++ streams is stateful, drop down to C is required
|
|
|
|
// Alternatively we could use stringstream, but its performance is... not good.
|
|
|
|
std::string getFormattedDuration( double duration ) {
|
|
|
|
// Max exponent + 1 is required to represent the whole part
|
|
|
|
// + 1 for decimal point
|
|
|
|
// + 3 for the 3 decimal places
|
|
|
|
// + 1 for null terminator
|
2017-09-18 18:13:17 +02:00
|
|
|
const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;
|
2017-07-10 11:33:18 +02:00
|
|
|
char buffer[maxDoubleSize];
|
2018-11-05 20:01:25 +01:00
|
|
|
|
2017-07-10 11:33:18 +02:00
|
|
|
// Save previous errno, to prevent sprintf from overwriting it
|
|
|
|
ErrnoGuard guard;
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
sprintf_s(buffer, "%.3f", duration);
|
|
|
|
#else
|
2019-02-13 22:06:41 +01:00
|
|
|
std::sprintf(buffer, "%.3f", duration);
|
2017-07-10 11:33:18 +02:00
|
|
|
#endif
|
|
|
|
return std::string(buffer);
|
|
|
|
}
|
|
|
|
|
2020-04-13 14:34:27 +02:00
|
|
|
bool shouldShowDuration( IConfig const& config, double duration ) {
|
|
|
|
if( config.showDurations() == ShowDurations::Always )
|
|
|
|
return true;
|
|
|
|
double min = config.minDuration();
|
|
|
|
return min >= 0 && duration >= min;
|
|
|
|
}
|
|
|
|
|
2019-04-01 21:33:57 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
return oss.str();
|
|
|
|
}
|
2017-07-10 11:33:18 +02:00
|
|
|
|
|
|
|
TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config)
|
|
|
|
:StreamingReporterBase(_config) {}
|
|
|
|
|
2018-11-05 20:01:25 +01:00
|
|
|
std::set<Verbosity> TestEventListenerBase::getSupportedVerbosities() {
|
|
|
|
return { Verbosity::Quiet, Verbosity::Normal, Verbosity::High };
|
|
|
|
}
|
|
|
|
|
2017-07-10 11:33:18 +02:00
|
|
|
void TestEventListenerBase::assertionStarting(AssertionInfo const &) {}
|
|
|
|
|
|
|
|
bool TestEventListenerBase::assertionEnded(AssertionStats const &) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace Catch
|