Index: Source/core/html/TimeRangesTest.cpp |
diff --git a/Source/core/html/TimeRangesTest.cpp b/Source/core/html/TimeRangesTest.cpp |
index 7621f2b1a19725b63abac7819d68faaf4e771414..e4b11d6ceadccebc51fcbbbc6cbc9fcbf515a58a 100644 |
--- a/Source/core/html/TimeRangesTest.cpp |
+++ b/Source/core/html/TimeRangesTest.cpp |
@@ -298,3 +298,18 @@ 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)); |
+ ASSERT_EQ(1, ranges->nearest(1)); |
+ ASSERT_EQ(2, ranges->nearest(2)); |
+ ASSERT_EQ(2, ranges->nearest(3)); |
philipj_slow
2014/09/10 12:51:18
Can you also test the case where the point is exac
DaleCurtis
2014/09/10 17:45:19
Damn, you caught me! :) I was trying to avoid any
|
+ ASSERT_EQ(5, ranges->nearest(4)); |
+ ASSERT_EQ(5, ranges->nearest(5)); |
+ ASSERT_EQ(7, ranges->nearest(8)); |
+} |