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

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: Address more CR comments and added an end of stream test case. 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
« no previous file with comments | « media/base/ranges.h ('k') | media/filters/chunk_demuxer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/ranges_unittest.cc
diff --git a/media/base/ranges_unittest.cc b/media/base/ranges_unittest.cc
index 30c00b083884428936586c99cb318bc4b9753515..967d138cea1fb829ce6b0c78bb0c3c7c4277bbaa 100644
--- a/media/base/ranges_unittest.cc
+++ b/media/base/ranges_unittest.cc
@@ -99,4 +99,53 @@ 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.
+ 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) }");
+
+ // Test intersection with a range that starts at the beginning of the
+ // first range and ends at the end of the last range.
+ b.clear();
+ ASSERT_EQ(b.Add(0, 12), 1u) << b;
+ ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }");
+ ASSERT_RANGES(b, "{ [0,12) }");
+ ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [4,7) [10,12) }");
+ ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [4,7) [10,12) }");
+}
+
} // namespace media
« no previous file with comments | « media/base/ranges.h ('k') | media/filters/chunk_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698