OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 using std::swap; | 170 using std::swap; |
171 swap(buf1, buf2); | 171 swap(buf1, buf2); |
172 EXPECT_EQ(buf1.size(), 6u); | 172 EXPECT_EQ(buf1.size(), 6u); |
173 EXPECT_EQ(buf1.capacity(), 40u); | 173 EXPECT_EQ(buf1.capacity(), 40u); |
174 EXPECT_EQ(buf1.data(), data2); | 174 EXPECT_EQ(buf1.data(), data2); |
175 EXPECT_EQ(buf2.size(), 3u); | 175 EXPECT_EQ(buf2.size(), 3u); |
176 EXPECT_EQ(buf2.capacity(), 3u); | 176 EXPECT_EQ(buf2.capacity(), 3u); |
177 EXPECT_EQ(buf2.data(), data1); | 177 EXPECT_EQ(buf2.data(), data1); |
178 } | 178 } |
179 | 179 |
| 180 TEST(BufferTest, TestClear) { |
| 181 Buffer buf; |
| 182 buf.SetData(kTestData, 15); |
| 183 EXPECT_EQ(buf.size(), 15u); |
| 184 EXPECT_EQ(buf.capacity(), 15u); |
| 185 const char *data = buf.data<char>(); |
| 186 buf.Clear(); |
| 187 EXPECT_EQ(buf.size(), 0u); |
| 188 EXPECT_EQ(buf.capacity(), 15u); // Hasn't shrunk. |
| 189 EXPECT_EQ(buf.data<char>(), data); // No reallocation. |
| 190 } |
| 191 |
180 } // namespace rtc | 192 } // namespace rtc |
OLD | NEW |