| OLD | NEW |
| 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 "media/base/ranges.h" |
| 6 |
| 5 #include <sstream> | 7 #include <sstream> |
| 6 | 8 |
| 7 #include "media/base/ranges.h" | 9 #include "base/strings/string_piece.h" |
| 8 | |
| 9 #include "base/string_piece.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 // Human-readable output operator, for debugging/testability. | 14 // Human-readable output operator, for debugging/testability. |
| 15 template<class T> | 15 template<class T> |
| 16 std::ostream& operator<<(std::ostream& os, const Ranges<T>& r) { | 16 std::ostream& operator<<(std::ostream& os, const Ranges<T>& r) { |
| 17 os << "{ "; | 17 os << "{ "; |
| 18 for(size_t i = 0; i < r.size(); ++i) | 18 for(size_t i = 0; i < r.size(); ++i) |
| 19 os << "[" << r.start(i) << "," << r.end(i) << ") "; | 19 os << "[" << r.start(i) << "," << r.end(i) << ") "; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // first range and ends at the end of the last range. | 142 // first range and ends at the end of the last range. |
| 143 b.clear(); | 143 b.clear(); |
| 144 ASSERT_EQ(b.Add(0, 12), 1u) << b; | 144 ASSERT_EQ(b.Add(0, 12), 1u) << b; |
| 145 ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }"); | 145 ASSERT_RANGES(a, "{ [0,1) [4,7) [10,12) }"); |
| 146 ASSERT_RANGES(b, "{ [0,12) }"); | 146 ASSERT_RANGES(b, "{ [0,12) }"); |
| 147 ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [4,7) [10,12) }"); | 147 ASSERT_RANGES(a.IntersectionWith(b), "{ [0,1) [4,7) [10,12) }"); |
| 148 ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [4,7) [10,12) }"); | 148 ASSERT_RANGES(b.IntersectionWith(a), "{ [0,1) [4,7) [10,12) }"); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace media | 151 } // namespace media |
| OLD | NEW |