1 /* 2 * Created by Phil on 27/11/2013. 3 * Copyright 2013 Two Blue Cubes Ltd. All rights reserved. 4 * 5 * Distributed under the Boost Software License, Version 1.0. (See accompanying 6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 9 #include "../internal/catch_interfaces_reporter.h" 10 #include "../internal/catch_errno_guard.h" 11 #include "catch_reporter_bases.hpp" 12 13 #include <cstring> 14 #include <cfloat> 15 #include <cstdio> 16 #include <cassert> 17 #include <memory> 18 19 namespace Catch { prepareExpandedExpression(AssertionResult & result)20 void prepareExpandedExpression(AssertionResult& result) { 21 result.getExpandedExpression(); 22 } 23 24 // Because formatting using c++ streams is stateful, drop down to C is required 25 // Alternatively we could use stringstream, but its performance is... not good. getFormattedDuration(double duration)26 std::string getFormattedDuration( double duration ) { 27 // Max exponent + 1 is required to represent the whole part 28 // + 1 for decimal point 29 // + 3 for the 3 decimal places 30 // + 1 for null terminator 31 const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1; 32 char buffer[maxDoubleSize]; 33 34 // Save previous errno, to prevent sprintf from overwriting it 35 ErrnoGuard guard; 36 #ifdef _MSC_VER 37 sprintf_s(buffer, "%.3f", duration); 38 #else 39 std::sprintf(buffer, "%.3f", duration); 40 #endif 41 return std::string(buffer); 42 } 43 serializeFilters(std::vector<std::string> const & container)44 std::string serializeFilters( std::vector<std::string> const& container ) { 45 ReusableStringStream oss; 46 bool first = true; 47 for (auto&& filter : container) 48 { 49 if (!first) 50 oss << ' '; 51 else 52 first = false; 53 54 oss << filter; 55 } 56 return oss.str(); 57 } 58 TestEventListenerBase(ReporterConfig const & _config)59 TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config) 60 :StreamingReporterBase(_config) {} 61 getSupportedVerbosities()62 std::set<Verbosity> TestEventListenerBase::getSupportedVerbosities() { 63 return { Verbosity::Quiet, Verbosity::Normal, Verbosity::High }; 64 } 65 assertionStarting(AssertionInfo const &)66 void TestEventListenerBase::assertionStarting(AssertionInfo const &) {} 67 assertionEnded(AssertionStats const &)68 bool TestEventListenerBase::assertionEnded(AssertionStats const &) { 69 return false; 70 } 71 72 73 } // end namespace Catch 74