Adds debug printing of units in unit tests.
Bug: webrtc:9656 Change-Id: I643b79bc214643f47b2b64967ce713665dbef5c9 Reviewed-on: https://webrtc-review.googlesource.com/95652 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24436}
This commit is contained in:

committed by
Commit Bot

parent
1946a3f0fe
commit
2afd281ec4
@ -20,7 +20,11 @@ std::string ToString(const DataRate& value) {
|
||||
if (value.IsInfinite()) {
|
||||
sb << "inf bps";
|
||||
} else {
|
||||
sb << value.bps() << " bps";
|
||||
if (value.bps() == 0 || value.bps() % 1000 != 0) {
|
||||
sb << value.bps() << " bps";
|
||||
} else {
|
||||
sb << value.kbps() << " kbps";
|
||||
}
|
||||
}
|
||||
return sb.str();
|
||||
}
|
||||
|
@ -10,6 +10,11 @@
|
||||
|
||||
#ifndef API_UNITS_DATA_RATE_H_
|
||||
#define API_UNITS_DATA_RATE_H_
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
#include <ostream> // no-presubmit-check TODO(webrtc:8982)
|
||||
#endif // UNIT_TEST
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
@ -197,6 +202,14 @@ inline DataSize operator*(const TimeDelta& duration, const DataRate& rate) {
|
||||
|
||||
std::string ToString(const DataRate& value);
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982)
|
||||
std::ostream& stream, // no-presubmit-check TODO(webrtc:8982)
|
||||
DataRate value) {
|
||||
return stream << ToString(value);
|
||||
}
|
||||
#endif // UNIT_TEST
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_UNITS_DATA_RATE_H_
|
||||
|
@ -11,6 +11,10 @@
|
||||
#ifndef API_UNITS_DATA_SIZE_H_
|
||||
#define API_UNITS_DATA_SIZE_H_
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
#include <ostream> // no-presubmit-check TODO(webrtc:8982)
|
||||
#endif // UNIT_TEST
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
@ -149,6 +153,14 @@ inline DataSize operator/(const DataSize& size, const int64_t& scalar) {
|
||||
|
||||
std::string ToString(const DataSize& value);
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982)
|
||||
std::ostream& stream, // no-presubmit-check TODO(webrtc:8982)
|
||||
DataSize value) {
|
||||
return stream << ToString(value);
|
||||
}
|
||||
#endif // UNIT_TEST
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_UNITS_DATA_SIZE_H_
|
||||
|
@ -22,7 +22,12 @@ std::string ToString(const TimeDelta& value) {
|
||||
} else if (value.IsMinusInfinity()) {
|
||||
sb << "-inf ms";
|
||||
} else {
|
||||
sb << value.ms() << " ms";
|
||||
if (value.us() == 0 || (value.us() % 1000) != 0)
|
||||
sb << value.us() << " us";
|
||||
else if (value.ms() % 1000 != 0)
|
||||
sb << value.ms() << " ms";
|
||||
else
|
||||
sb << value.seconds() << " s";
|
||||
}
|
||||
return sb.str();
|
||||
}
|
||||
|
@ -11,6 +11,10 @@
|
||||
#ifndef API_UNITS_TIME_DELTA_H_
|
||||
#define API_UNITS_TIME_DELTA_H_
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
#include <ostream> // no-presubmit-check TODO(webrtc:8982)
|
||||
#endif // UNIT_TEST
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
@ -253,6 +257,15 @@ inline TimeDelta operator/(const TimeDelta& delta, const int64_t& scalar) {
|
||||
return TimeDelta::us(delta.us() / scalar);
|
||||
}
|
||||
std::string ToString(const TimeDelta& value);
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982)
|
||||
std::ostream& stream, // no-presubmit-check TODO(webrtc:8982)
|
||||
TimeDelta value) {
|
||||
return stream << ToString(value);
|
||||
}
|
||||
#endif // UNIT_TEST
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_UNITS_TIME_DELTA_H_
|
||||
|
@ -19,7 +19,10 @@ std::string ToString(const Timestamp& value) {
|
||||
if (value.IsInfinite()) {
|
||||
sb << "inf ms";
|
||||
} else {
|
||||
sb << value.ms() << " ms";
|
||||
if (value.ms() % 1000 == 0)
|
||||
sb << value.seconds() << " s";
|
||||
else
|
||||
sb << value.ms() << " ms";
|
||||
}
|
||||
return sb.str();
|
||||
}
|
||||
|
@ -11,6 +11,10 @@
|
||||
#ifndef API_UNITS_TIMESTAMP_H_
|
||||
#define API_UNITS_TIMESTAMP_H_
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
#include <ostream> // no-presubmit-check TODO(webrtc:8982)
|
||||
#endif // UNIT_TEST
|
||||
|
||||
#include <stdint.h>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
@ -203,6 +207,14 @@ class Timestamp {
|
||||
|
||||
std::string ToString(const Timestamp& value);
|
||||
|
||||
#ifdef UNIT_TEST
|
||||
inline std::ostream& operator<<( // no-presubmit-check TODO(webrtc:8982)
|
||||
std::ostream& stream, // no-presubmit-check TODO(webrtc:8982)
|
||||
Timestamp value) {
|
||||
return stream << ToString(value);
|
||||
}
|
||||
#endif // UNIT_TEST
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_UNITS_TIMESTAMP_H_
|
||||
|
Reference in New Issue
Block a user