File tree Expand file tree Collapse file tree 2 files changed +9
-17
lines changed
inst/include/testthat/vendor Expand file tree Collapse file tree 2 files changed +9
-17
lines changed Original file line number Diff line number Diff line change 11# testthat (development version)
22
3+ * The embedded version of Catch no longer uses ` sprintf() ` .
4+
35# testthat 3.1.5
46
57* Deprecation warnings are no longer captured by ` expect_warning(code, NA) ` ,
Original file line number Diff line number Diff line change @@ -9473,6 +9473,10 @@ Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingRepo
94739473// #included from: catch_reporter_bases.hpp
94749474#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
94759475
9476+ #include < iomanip>
9477+ #include < iostream>
9478+ #include < sstream>
9479+
94769480#include < cstring>
94779481#include < cfloat>
94789482#include < cstdio>
@@ -9481,24 +9485,10 @@ Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingRepo
94819485namespace Catch {
94829486
94839487 namespace {
9484- // Because formatting using c++ streams is stateful, drop down to C is required
9485- // Alternatively we could use stringstream, but its performance is... not good.
94869488 std::string getFormattedDuration ( double duration ) {
9487- // Max exponent + 1 is required to represent the whole part
9488- // + 1 for decimal point
9489- // + 3 for the 3 decimal places
9490- // + 1 for null terminator
9491- const size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1 ;
9492- char buffer[maxDoubleSize];
9493-
9494- // Save previous errno, to prevent sprintf from overwriting it
9495- ErrnoGuard guard;
9496- #ifdef _MSC_VER
9497- sprintf_s (buffer, " %.3f" , duration);
9498- #else
9499- sprintf (buffer, " %.3f" , duration);
9500- #endif
9501- return std::string (buffer);
9489+ std::stringstream ss;
9490+ ss << std::setprecision (4 ) << duration;
9491+ return ss.str ();
95029492 }
95039493 }
95049494
You can’t perform that action at this time.
0 commit comments