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

Unified Diff: media/filters/vp9_raw_bits_reader_unittest.cc

Issue 1258083003: Add VP9 raw bits reader (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 4 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
« no previous file with comments | « media/filters/vp9_raw_bits_reader.cc ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/vp9_raw_bits_reader_unittest.cc
diff --git a/media/filters/vp9_raw_bits_reader_unittest.cc b/media/filters/vp9_raw_bits_reader_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d798f226c21b8fb0f1fa712008b70fa1f8e59b99
--- /dev/null
+++ b/media/filters/vp9_raw_bits_reader_unittest.cc
@@ -0,0 +1,66 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/filters/vp9_raw_bits_reader.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace media {
+
+TEST(Vp9RawBitsReaderTest, ReadBit) {
+ uint8_t data[] = {0xf1};
+ Vp9RawBitsReader reader;
+ reader.Initialize(data, 1);
+
+ EXPECT_TRUE(reader.IsValid());
+ EXPECT_EQ(0u, reader.GetBytesRead());
+ EXPECT_EQ(1, reader.ReadBit());
+ EXPECT_EQ(1u, reader.GetBytesRead());
+ EXPECT_EQ(1, reader.ReadBit());
+ EXPECT_EQ(1, reader.ReadBit());
+ EXPECT_EQ(1, reader.ReadBit());
+ EXPECT_EQ(0, reader.ReadBit());
+ EXPECT_EQ(0, reader.ReadBit());
+ EXPECT_EQ(0, reader.ReadBit());
+ EXPECT_EQ(1, reader.ReadBit());
+ EXPECT_TRUE(reader.IsValid());
+
+ // The return value is undefined.
+ ignore_result(reader.ReadBit());
+ EXPECT_FALSE(reader.IsValid());
+ EXPECT_EQ(1u, reader.GetBytesRead());
+}
+
+TEST(Vp9RawBitsReader, ReadLiteral) {
+ uint8_t data[] = {0x3d, 0x67, 0x9a};
+ Vp9RawBitsReader reader;
+ reader.Initialize(data, 3);
+
+ EXPECT_TRUE(reader.IsValid());
+ EXPECT_EQ(0x03, reader.ReadLiteral(4));
+ EXPECT_EQ(0xd679, reader.ReadLiteral(16));
+ EXPECT_TRUE(reader.IsValid());
+
+ // The return value is undefined.
+ ignore_result(reader.ReadLiteral(8));
+ EXPECT_FALSE(reader.IsValid());
+ EXPECT_EQ(3u, reader.GetBytesRead());
+}
+
+TEST(Vp9RawBitsReader, ReadSignedLiteral) {
+ uint8_t data[] = {0x3d, 0x67, 0x9a};
+ Vp9RawBitsReader reader;
+ reader.Initialize(data, 3);
+
+ EXPECT_TRUE(reader.IsValid());
+ EXPECT_EQ(-0x03, reader.ReadSignedLiteral(4));
+ EXPECT_EQ(-0x5679, reader.ReadSignedLiteral(15));
+ EXPECT_TRUE(reader.IsValid());
+
+ // The return value is undefined.
+ ignore_result(reader.ReadSignedLiteral(7));
+ EXPECT_FALSE(reader.IsValid());
+ EXPECT_EQ(3u, reader.GetBytesRead());
+}
+
+} // namespace media
« no previous file with comments | « media/filters/vp9_raw_bits_reader.cc ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698