Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorkhyperia2020-02-26 15:32:34 +0100
committerMartin Hořeňovský2020-04-29 16:54:46 +0200
commitefbfaa1704665bca48c6f13378a699e8b92e4796 (patch)
treee47360df9b3e5d9f07a24f66ecb0d3db70a19907
parentc4e5b05cfc3305fa1b3aa5265eb4192c71df16aa (diff)
downloadcatch3-efbfaa1704665bca48c6f13378a699e8b92e4796.tar.gz
Don't cast nanoseconds to integers when writing output
-rw-r--r--src/catch2/reporters/catch_reporter_console.cpp12
-rw-r--r--src/catch2/reporters/catch_reporter_xml.cpp10
2 files changed, 9 insertions, 13 deletions
diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp
index db97296b..bd016144 100644
--- a/src/catch2/reporters/catch_reporter_console.cpp
+++ b/src/catch2/reporters/catch_reporter_console.cpp
@@ -211,15 +211,11 @@ class Duration {
static const uint64_t s_nanosecondsInASecond = 1000 * s_nanosecondsInAMillisecond;
static const uint64_t s_nanosecondsInAMinute = 60 * s_nanosecondsInASecond;
- uint64_t m_inNanoseconds;
+ double m_inNanoseconds;
Unit m_units;
public:
- explicit Duration(double inNanoseconds, Unit units = Unit::Auto)
- : Duration(static_cast<uint64_t>(inNanoseconds), units) {
- }
-
- explicit Duration(uint64_t inNanoseconds, Unit units = Unit::Auto)
+ explicit Duration(double inNanoseconds, Unit units = Unit::Auto)
: m_inNanoseconds(inNanoseconds),
m_units(units) {
if (m_units == Unit::Auto) {
@@ -248,7 +244,7 @@ public:
case Unit::Minutes:
return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMinute);
default:
- return static_cast<double>(m_inNanoseconds);
+ return m_inNanoseconds;
}
}
StringRef unitsAsString() const {
@@ -695,4 +691,4 @@ void ConsoleReporter::printTestFilters() {
#if defined(__clang__)
# pragma clang diagnostic pop
-#endif \ No newline at end of file
+#endif
diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp
index 22053e85..1f6f0329 100644
--- a/src/catch2/reporters/catch_reporter_xml.cpp
+++ b/src/catch2/reporters/catch_reporter_xml.cpp
@@ -229,16 +229,16 @@ namespace Catch {
m_xml.writeAttribute("samples", info.samples)
.writeAttribute("resamples", info.resamples)
.writeAttribute("iterations", info.iterations)
- .writeAttribute("clockResolution", static_cast<uint64_t>(info.clockResolution))
- .writeAttribute("estimatedDuration", static_cast<uint64_t>(info.estimatedDuration))
+ .writeAttribute("clockResolution", info.clockResolution)
+ .writeAttribute("estimatedDuration", info.estimatedDuration)
.writeComment("All values in nano seconds");
}
void XmlReporter::benchmarkEnded(BenchmarkStats<> const& benchmarkStats) {
m_xml.startElement("mean")
- .writeAttribute("value", static_cast<uint64_t>(benchmarkStats.mean.point.count()))
- .writeAttribute("lowerBound", static_cast<uint64_t>(benchmarkStats.mean.lower_bound.count()))
- .writeAttribute("upperBound", static_cast<uint64_t>(benchmarkStats.mean.upper_bound.count()))
+ .writeAttribute("value", benchmarkStats.mean.point.count())
+ .writeAttribute("lowerBound", benchmarkStats.mean.lower_bound.count())
+ .writeAttribute("upperBound", benchmarkStats.mean.upper_bound.count())
.writeAttribute("ci", benchmarkStats.mean.confidence_interval);
m_xml.endElement();
m_xml.startElement("standardDeviation")