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

Unified Diff: webrtc/base/bitbuffer_unittest.cc

Issue 1314473008: H264 bitstream parser. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: add basic unittests Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/base/bitbuffer_unittest.cc
diff --git a/webrtc/base/bitbuffer_unittest.cc b/webrtc/base/bitbuffer_unittest.cc
index c47f92c59d332c738b4da903fd651d3bad2311ed..b9c348eb0d0030e4fc01722182d1697524f65131 100644
--- a/webrtc/base/bitbuffer_unittest.cc
+++ b/webrtc/base/bitbuffer_unittest.cc
@@ -205,6 +205,25 @@ TEST(BitBufferTest, GolombUint32Values) {
}
}
+TEST(BitBufferTest, SignedGolombValues) {
+ uint8_t golomb_bits[] = {
+ 0x80, // 1
+ 0x40, // 010
+ 0x60, // 011
+ 0x20, // 00100
+ 0x38, // 00111
+ };
+ int32_t expected[] = {0, 1, -1, 2, -3};
+ for (size_t i = 0; i < sizeof(golomb_bits); ++i) {
+ BitBuffer buffer(&golomb_bits[i], 1);
+ int32_t decoded_val;
+ ASSERT_TRUE(buffer.ReadSignedExponentialGolomb(&decoded_val));
+ EXPECT_EQ(expected[i], decoded_val)
+ << "Mismatch in expected/decoded value for golomb_bits[" << i
+ << "]: " << static_cast<int>(golomb_bits[i]);
+ }
+}
+
TEST(BitBufferTest, NoGolombOverread) {
const uint8 bytes[] = {0x00, 0xFF, 0xFF};
// Make sure the bit buffer correctly enforces byte length on golomb reads.

Powered by Google App Engine
This is Rietveld 408576698