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

Unified Diff: media/base/ranges_unittest.cc

Issue 10558011: Fix ChunkDemuxer so it properly outputs buffered ranges. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed everything to use media::Ranges. Created 8 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
Index: media/base/ranges_unittest.cc
diff --git a/media/base/ranges_unittest.cc b/media/base/ranges_unittest.cc
index 30c00b083884428936586c99cb318bc4b9753515..7dc197ba409821be5d45bca197dbab5b2b76ebf1 100644
--- a/media/base/ranges_unittest.cc
+++ b/media/base/ranges_unittest.cc
@@ -99,4 +99,44 @@ TEST(RangesTest, CoalesceRanges) {
ASSERT_RANGES(r, "{ [0,2) }");
}
+TEST(RangesTest, IntersectionWith) {
+ Ranges<int> a;
+ Ranges<int> b;
+
+ ASSERT_EQ(a.Add(0, 1), 1u) << a;
+ ASSERT_EQ(a.Add(4, 7), 2u) << a;
+ ASSERT_EQ(a.Add(10, 12), 3u) << a;
+
+ // Test intersections with an empty range.
+ ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }");
+ ASSERT_RANGES(b, "{ }");
+ ASSERT_RANGES(a.IntersectionWith(b), "{ }");
+ ASSERT_RANGES(b.IntersectionWith(a), "{ }");
+
+ // Test intersections with a completely overlaping range.
+ ASSERT_EQ(b.Add(-1, 13), 1u) << b;
+ ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }");
+ ASSERT_RANGES(b, "{ [-1,13) }");
+ ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [4,7) [10,12) }");
+ ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [4,7) [10,12) }");
+
+ // Test intersections with a disjoint ranges.
+ b.clear();
+ ASSERT_EQ(b.Add(1, 4), 1u) << b;
+ ASSERT_EQ(b.Add(8, 9), 2u) << b;
+ ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }");
+ ASSERT_RANGES(b, "{ [1,4) [8,9) }");
+ ASSERT_RANGES(a.IntersectionWith(b), "{ }");
+ ASSERT_RANGES(b.IntersectionWith(a), "{ }");
+
+ // Test intersections with partially overlapping ranges.
Ami GONE FROM CHROMIUM 2012/06/19 17:40:37 Since the incrementing works based on comparing th
acolwell GONE FROM CHROMIUM 2012/06/19 19:50:15 Done.
+ b.clear();
+ ASSERT_EQ(b.Add(0, 3), 1u) << b;
+ ASSERT_EQ(b.Add(5, 11), 2u) << b;
+ ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }");
+ ASSERT_RANGES(b, "{ [0,3) [5,11) }");
+ ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [5,7) [10,11) }");
+ ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [5,7) [10,11) }");
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698