Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1753)

Unified Diff: net/quic/congestion_control/windowed_filter_test.cc

Issue 2036613002: net::WindowedFilterTest: Add explicit overflow checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Add comments for ASSERTS Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/congestion_control/windowed_filter_test.cc
diff --git a/net/quic/congestion_control/windowed_filter_test.cc b/net/quic/congestion_control/windowed_filter_test.cc
index 3648422469be05de6ba1a27f17feb42e56fb468e..25870b864586e79d3ab6335579c50a683c958762 100644
--- a/net/quic/congestion_control/windowed_filter_test.cc
+++ b/net/quic/congestion_control/windowed_filter_test.cc
@@ -152,6 +152,10 @@ TEST_F(WindowedFilterTest, SampleChangesThirdBestMin) {
// RTT sample lower than the third-choice min-rtt sets that, but nothing else.
QuicTime::Delta rtt_sample = windowed_min_rtt_.GetThirdBest().Subtract(
QuicTime::Delta::FromMilliseconds(5));
+ // This assert is necessary to avoid triggering -Wstrict-overflow
+ // See crbug/616957
+ ASSERT_GT(windowed_min_rtt_.GetThirdBest(),
+ QuicTime::Delta::FromMilliseconds(5));
// Latest sample was recorded at 100ms.
QuicTime now = QuicTime::Zero().Add(QuicTime::Delta::FromMilliseconds(101));
windowed_min_rtt_.Update(rtt_sample, now);
@@ -181,6 +185,10 @@ TEST_F(WindowedFilterTest, SampleChangesSecondBestMin) {
// the third-choice min.
QuicTime::Delta rtt_sample = windowed_min_rtt_.GetSecondBest().Subtract(
QuicTime::Delta::FromMilliseconds(5));
+ // This assert is necessary to avoid triggering -Wstrict-overflow
+ // See crbug/616957
+ ASSERT_GT(windowed_min_rtt_.GetSecondBest(),
+ QuicTime::Delta::FromMilliseconds(5));
// Latest sample was recorded at 100ms.
QuicTime now = QuicTime::Zero().Add(QuicTime::Delta::FromMilliseconds(101));
windowed_min_rtt_.Update(rtt_sample, now);
@@ -209,6 +217,9 @@ TEST_F(WindowedFilterTest, SampleChangesAllMins) {
// the second and third-choice mins.
QuicTime::Delta rtt_sample = windowed_min_rtt_.GetBest().Subtract(
QuicTime::Delta::FromMilliseconds(5));
+ // This assert is necessary to avoid triggering -Wstrict-overflow
+ // See crbug/616957
+ ASSERT_GT(windowed_min_rtt_.GetBest(), QuicTime::Delta::FromMilliseconds(5));
// Latest sample was recorded at 100ms.
QuicTime now = QuicTime::Zero().Add(QuicTime::Delta::FromMilliseconds(101));
windowed_min_rtt_.Update(rtt_sample, now);
@@ -289,6 +300,11 @@ TEST_F(WindowedFilterTest, ExpireAllMins) {
InitializeMinFilter();
QuicTime::Delta rtt_sample = windowed_min_rtt_.GetThirdBest().Add(
QuicTime::Delta::FromMilliseconds(5));
+ // This assert is necessary to avoid triggering -Wstrict-overflow
+ // See crbug/616957
+ ASSERT_LT(windowed_min_rtt_.GetThirdBest(),
+ QuicTime::Delta::Infinite().Subtract(
+ QuicTime::Delta::FromMilliseconds(5)));
// Third best min sample was recorded at 100ms, so expiry time is 199ms.
QuicTime now = QuicTime::Zero().Add(QuicTime::Delta::FromMilliseconds(200));
windowed_min_rtt_.Update(rtt_sample, now);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698