OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 EXPECT_EQ(0x00000000u, LatestTimestamp(0x00000000, 0xFFFF0000)); | 105 EXPECT_EQ(0x00000000u, LatestTimestamp(0x00000000, 0xFFFF0000)); |
106 EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0x0000FFFF, 0xFFFFFFFF)); | 106 EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0x0000FFFF, 0xFFFFFFFF)); |
107 EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0x0000FFFF, 0xFFFF0000)); | 107 EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0x0000FFFF, 0xFFFF0000)); |
108 | 108 |
109 EXPECT_EQ(0x00000000u, LatestTimestamp(0xFFFFFFFF, 0x00000000)); | 109 EXPECT_EQ(0x00000000u, LatestTimestamp(0xFFFFFFFF, 0x00000000)); |
110 EXPECT_EQ(0x00000000u, LatestTimestamp(0xFFFF0000, 0x00000000)); | 110 EXPECT_EQ(0x00000000u, LatestTimestamp(0xFFFF0000, 0x00000000)); |
111 EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0xFFFFFFFF, 0x0000FFFF)); | 111 EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0xFFFFFFFF, 0x0000FFFF)); |
112 EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0xFFFF0000, 0x0000FFFF)); | 112 EXPECT_EQ(0x0000FFFFu, LatestTimestamp(0xFFFF0000, 0x0000FFFF)); |
113 } | 113 } |
114 | 114 |
115 TEST(ClampToInt16, TestCases) { | |
116 EXPECT_EQ(0x0000, ClampToInt16(0x00000000)); | |
117 EXPECT_EQ(0x0001, ClampToInt16(0x00000001)); | |
118 EXPECT_EQ(0x7FFF, ClampToInt16(0x00007FFF)); | |
119 EXPECT_EQ(0x7FFF, ClampToInt16(0x7FFFFFFF)); | |
120 EXPECT_EQ(-0x0001, ClampToInt16(-0x00000001)); | |
121 EXPECT_EQ(-0x8000, ClampToInt16(-0x8000)); | |
122 EXPECT_EQ(-0x8000, ClampToInt16(-0x7FFFFFFF)); | |
123 } | |
124 | 115 |
125 TEST(SequenceNumberUnwrapper, Limits) { | 116 TEST(SequenceNumberUnwrapper, Limits) { |
126 SequenceNumberUnwrapper unwrapper; | 117 SequenceNumberUnwrapper unwrapper; |
127 | 118 |
128 EXPECT_EQ(0, unwrapper.Unwrap(0)); | 119 EXPECT_EQ(0, unwrapper.Unwrap(0)); |
129 EXPECT_EQ(0x8000, unwrapper.Unwrap(0x8000)); | 120 EXPECT_EQ(0x8000, unwrapper.Unwrap(0x8000)); |
130 // Delta is exactly 0x8000 but current is lower than input, wrap backwards. | 121 // Delta is exactly 0x8000 but current is lower than input, wrap backwards. |
131 EXPECT_EQ(0x0, unwrapper.Unwrap(0x0000)); | 122 EXPECT_EQ(0x0, unwrapper.Unwrap(0x0000)); |
132 | 123 |
133 EXPECT_EQ(0x8000, unwrapper.Unwrap(0x8000)); | 124 EXPECT_EQ(0x8000, unwrapper.Unwrap(0x8000)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 166 |
176 seq = kNumWraps * 0xFFFF; | 167 seq = kNumWraps * 0xFFFF; |
177 unwrapper.UpdateLast(seq); | 168 unwrapper.UpdateLast(seq); |
178 for (; seq >= 0; --seq) { | 169 for (; seq >= 0; --seq) { |
179 int64_t unwrapped = unwrapper.Unwrap(static_cast<uint16_t>(seq & 0xFFFF)); | 170 int64_t unwrapped = unwrapper.Unwrap(static_cast<uint16_t>(seq & 0xFFFF)); |
180 EXPECT_EQ(seq, unwrapped); | 171 EXPECT_EQ(seq, unwrapped); |
181 } | 172 } |
182 } | 173 } |
183 | 174 |
184 } // namespace webrtc | 175 } // namespace webrtc |
OLD | NEW |