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

Unified Diff: Source/core/html/TimeRangesTest.cpp

Issue 559993004: Fix TimeRanges::nearest() to actually calculate nearest time. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Comments. Created 6 years, 3 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
« Source/core/html/TimeRanges.cpp ('K') | « Source/core/html/TimeRanges.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/TimeRangesTest.cpp
diff --git a/Source/core/html/TimeRangesTest.cpp b/Source/core/html/TimeRangesTest.cpp
index 7621f2b1a19725b63abac7819d68faaf4e771414..aab2e9d4ffb3065a0ebc3d4861634e1de7679ede 100644
--- a/Source/core/html/TimeRangesTest.cpp
+++ b/Source/core/html/TimeRangesTest.cpp
@@ -298,3 +298,23 @@ TEST(TimeRanges, IntersectWith_Gaps3)
ASSERT_RANGE("{ [1,2) [4,5) [6,7) [8,9) }", rangesA);
ASSERT_RANGE("{ [1,5) [6,9) }", rangesB);
}
+
+TEST(TimeRanges, Nearest)
+{
+ RefPtrWillBeRawPtr<TimeRanges> ranges = TimeRanges::create();
+ ranges->add(0, 2);
+ ranges->add(5, 7);
+
+ ASSERT_EQ(0, ranges->nearest(0, 0));
+ ASSERT_EQ(1, ranges->nearest(1, 0));
+ ASSERT_EQ(2, ranges->nearest(2, 0));
+ ASSERT_EQ(2, ranges->nearest(3, 0));
+ ASSERT_EQ(5, ranges->nearest(4, 0));
+ ASSERT_EQ(5, ranges->nearest(5, 0));
+ ASSERT_EQ(7, ranges->nearest(8, 0));
+
+ ranges->add(9, 11);
+ ASSERT_EQ(7, ranges->nearest(8, 6));
+ ASSERT_EQ(7, ranges->nearest(8, 8));
+ ASSERT_EQ(9, ranges->nearest(8, 10));
+}
« Source/core/html/TimeRanges.cpp ('K') | « Source/core/html/TimeRanges.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698