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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <sstream>
6 6
7 #include "media/base/ranges.h" 7 #include "media/base/ranges.h"
8 8
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 ASSERT_EQ(r.Add(4, 5), 3u) << r; 92 ASSERT_EQ(r.Add(4, 5), 3u) << r;
93 ASSERT_EQ(r.Add(0.5, 4.5), 1u) << r; 93 ASSERT_EQ(r.Add(0.5, 4.5), 1u) << r;
94 ASSERT_RANGES(r, "{ [0,5) }"); 94 ASSERT_RANGES(r, "{ [0,5) }");
95 95
96 r.clear(); 96 r.clear();
97 ASSERT_EQ(r.Add(0, 1), 1u) << r; 97 ASSERT_EQ(r.Add(0, 1), 1u) << r;
98 ASSERT_EQ(r.Add(1, 2), 1u) << r; 98 ASSERT_EQ(r.Add(1, 2), 1u) << r;
99 ASSERT_RANGES(r, "{ [0,2) }"); 99 ASSERT_RANGES(r, "{ [0,2) }");
100 } 100 }
101 101
102 TEST(RangesTest, IntersectionWith) {
103 Ranges<int> a;
104 Ranges<int> b;
105
106 ASSERT_EQ(a.Add(0, 1), 1u) << a;
107 ASSERT_EQ(a.Add(4, 7), 2u) << a;
108 ASSERT_EQ(a.Add(10, 12), 3u) << a;
109
110 // Test intersections with an empty range.
111 ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }");
112 ASSERT_RANGES(b, "{ }");
113 ASSERT_RANGES(a.IntersectionWith(b), "{ }");
114 ASSERT_RANGES(b.IntersectionWith(a), "{ }");
115
116 // Test intersections with a completely overlaping range.
117 ASSERT_EQ(b.Add(-1, 13), 1u) << b;
118 ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }");
119 ASSERT_RANGES(b, "{ [-1,13) }");
120 ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [4,7) [10,12) }");
121 ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [4,7) [10,12) }");
122
123 // Test intersections with a disjoint ranges.
124 b.clear();
125 ASSERT_EQ(b.Add(1, 4), 1u) << b;
126 ASSERT_EQ(b.Add(8, 9), 2u) << b;
127 ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }");
128 ASSERT_RANGES(b, "{ [1,4) [8,9) }");
129 ASSERT_RANGES(a.IntersectionWith(b), "{ }");
130 ASSERT_RANGES(b.IntersectionWith(a), "{ }");
131
132 // 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.
133 b.clear();
134 ASSERT_EQ(b.Add(0, 3), 1u) << b;
135 ASSERT_EQ(b.Add(5, 11), 2u) << b;
136 ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }");
137 ASSERT_RANGES(b, "{ [0,3) [5,11) }");
138 ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [5,7) [10,11) }");
139 ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [5,7) [10,11) }");
140 }
141
102 } // namespace media 142 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698