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 44 TestEventListenerBase(ReporterConfig const & _config)45 TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config) 46 :StreamingReporterBase(_config) {} 47 getSupportedVerbosities()48 std::set<Verbosity> TestEventListenerBase::getSupportedVerbosities() { 49 return { Verbosity::Quiet, Verbosity::Normal, Verbosity::High }; 50 } 51 assertionStarting(AssertionInfo const &)52 void TestEventListenerBase::assertionStarting(AssertionInfo const &) {} 53 assertionEnded(AssertionStats const &)54 bool TestEventListenerBase::assertionEnded(AssertionStats const &) { 55 return false; 56 } 57 58 59 } // end namespace Catch 60