| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 x = 200; | 202 x = 200; |
| 203 for (int i = 0; i < D / 2; ++i) { | 203 for (int i = 0; i < D / 2; ++i) { |
| 204 seq_nums_asc.insert(x); | 204 seq_nums_asc.insert(x); |
| 205 seq_nums_desc.insert(x); | 205 seq_nums_desc.insert(x); |
| 206 ASSERT_EQ(x, *seq_nums_asc.begin()); | 206 ASSERT_EQ(x, *seq_nums_asc.begin()); |
| 207 ASSERT_EQ(x, *seq_nums_desc.rbegin()); | 207 ASSERT_EQ(x, *seq_nums_desc.rbegin()); |
| 208 x = Add<D>(x, 1); | 208 x = Add<D>(x, 1); |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 // TODO(philipel): Enable when downstream project can hande these death tests. | 212 #if GTEST_HAS_DEATH_TEST |
| 213 | 213 #if !defined(WEBRTC_ANDROID) |
| 214 TEST(SeqNumUnwrapper, DISABLED_NoBackWardWrap) { | 214 TEST(SeqNumUnwrapper, NoBackWardWrap) { |
| 215 SeqNumUnwrapper<uint8_t> unwrapper; | 215 SeqNumUnwrapper<uint8_t> unwrapper; |
| 216 EXPECT_EQ(0U, unwrapper.Unwrap(0)); | 216 EXPECT_EQ(0U, unwrapper.Unwrap(0)); |
| 217 | 217 |
| 218 // The unwrapped sequence is not allowed to wrap, if that happens the | 218 // The unwrapped sequence is not allowed to wrap, if that happens the |
| 219 // SeqNumUnwrapper should have been constructed with a higher start value. | 219 // SeqNumUnwrapper should have been constructed with a higher start value. |
| 220 ASSERT_DEATH_IF_SUPPORTED(unwrapper.Unwrap(255), ""); | 220 EXPECT_DEATH(unwrapper.Unwrap(255), ""); |
| 221 } | 221 } |
| 222 | 222 |
| 223 TEST(SeqNumUnwrapper, DISABLED_NoForwardWrap) { | 223 TEST(SeqNumUnwrapper, NoForwardWrap) { |
| 224 SeqNumUnwrapper<uint32_t> unwrapper(std::numeric_limits<uint64_t>::max()); | 224 SeqNumUnwrapper<uint32_t> unwrapper(std::numeric_limits<uint64_t>::max()); |
| 225 EXPECT_EQ(std::numeric_limits<uint64_t>::max(), unwrapper.Unwrap(0)); | 225 EXPECT_EQ(std::numeric_limits<uint64_t>::max(), unwrapper.Unwrap(0)); |
| 226 | 226 |
| 227 // The unwrapped sequence is not allowed to wrap, if that happens the | 227 // The unwrapped sequence is not allowed to wrap, if that happens the |
| 228 // SeqNumUnwrapper should have been constructed with a lower start value. | 228 // SeqNumUnwrapper should have been constructed with a lower start value. |
| 229 ASSERT_DEATH_IF_SUPPORTED(unwrapper.Unwrap(1), ""); | 229 EXPECT_DEATH(unwrapper.Unwrap(1), ""); |
| 230 } | 230 } |
| 231 #endif |
| 232 #endif |
| 231 | 233 |
| 232 TEST(SeqNumUnwrapper, ForwardWrap) { | 234 TEST(SeqNumUnwrapper, ForwardWrap) { |
| 233 SeqNumUnwrapper<uint8_t> unwrapper; | 235 SeqNumUnwrapper<uint8_t> unwrapper; |
| 234 EXPECT_EQ(0U, unwrapper.Unwrap(255)); | 236 EXPECT_EQ(0U, unwrapper.Unwrap(255)); |
| 235 EXPECT_EQ(1U, unwrapper.Unwrap(0)); | 237 EXPECT_EQ(1U, unwrapper.Unwrap(0)); |
| 236 } | 238 } |
| 237 | 239 |
| 238 TEST(SeqNumUnwrapper, ForwardWrapWithDivisor) { | 240 TEST(SeqNumUnwrapper, ForwardWrapWithDivisor) { |
| 239 SeqNumUnwrapper<uint8_t, 33> unwrapper; | 241 SeqNumUnwrapper<uint8_t, 33> unwrapper; |
| 240 EXPECT_EQ(0U, unwrapper.Unwrap(30)); | 242 EXPECT_EQ(0U, unwrapper.Unwrap(30)); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 uint16_t next_unwrap = 0; | 311 uint16_t next_unwrap = 0; |
| 310 uint64_t expected = kLargeNumber * kNumWraps; | 312 uint64_t expected = kLargeNumber * kNumWraps; |
| 311 for (uint16_t i = 0; i < kNumWraps * 2 + 1; ++i) { | 313 for (uint16_t i = 0; i < kNumWraps * 2 + 1; ++i) { |
| 312 EXPECT_EQ(expected, unwrapper.Unwrap(next_unwrap)); | 314 EXPECT_EQ(expected, unwrapper.Unwrap(next_unwrap)); |
| 313 expected -= kMaxStep; | 315 expected -= kMaxStep; |
| 314 next_unwrap = (next_unwrap + kMaxStep + 1) % kLargeNumber; | 316 next_unwrap = (next_unwrap + kMaxStep + 1) % kLargeNumber; |
| 315 } | 317 } |
| 316 } | 318 } |
| 317 | 319 |
| 318 } // namespace webrtc | 320 } // namespace webrtc |
| OLD | NEW |