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

Unified Diff: chrome/browser/net/bit_stream_reader_unittest.cc

Issue 811353002: Move CT EV white list packaging API from chrome/ to components/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed missed nit Created 5 years, 11 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 | « chrome/browser/net/bit_stream_reader.cc ('k') | chrome/browser/net/packed_ct_ev_whitelist.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/bit_stream_reader_unittest.cc
diff --git a/chrome/browser/net/bit_stream_reader_unittest.cc b/chrome/browser/net/bit_stream_reader_unittest.cc
deleted file mode 100644
index 766b2d12269a968ce0154c3bfb717d2610d357c2..0000000000000000000000000000000000000000
--- a/chrome/browser/net/bit_stream_reader_unittest.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2014 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 "chrome/browser/net/bit_stream_reader.h"
-
-#include <algorithm>
-#include <string>
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace internal {
-
-const uint8_t kSomeData[] = {0xd5, 0xe2, 0xaf, 0xe5, 0xbb, 0x10, 0x7c, 0xd1};
-
-TEST(BitStreamReaderTest, CanReadSingleByte) {
- BitStreamReader reader(
- base::StringPiece(reinterpret_cast<const char*>(kSomeData), 1));
- uint64_t v(0);
-
- EXPECT_EQ(8u, reader.BitsLeft());
- EXPECT_TRUE(reader.ReadBits(8, &v));
- EXPECT_EQ(UINT64_C(0xd5), v);
-
- EXPECT_FALSE(reader.ReadBits(1, &v));
- EXPECT_EQ(0u, reader.BitsLeft());
-}
-
-TEST(BitStreamReaderTest, CanReadSingleBits) {
- const uint64_t expected_bits[] = {
- 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0};
- BitStreamReader reader(
- base::StringPiece(reinterpret_cast<const char*>(kSomeData), 2));
- EXPECT_EQ(16u, reader.BitsLeft());
- uint64_t v(0);
-
- for (int i = 0; i < 16; ++i) {
- EXPECT_TRUE(reader.ReadBits(1, &v));
- EXPECT_EQ(expected_bits[i], v);
- }
- EXPECT_EQ(0u, reader.BitsLeft());
-}
-
-TEST(BitStreamReaderTest, CanReadBitGroups) {
- BitStreamReader reader(
- base::StringPiece(reinterpret_cast<const char*>(kSomeData), 3));
- EXPECT_EQ(24u, reader.BitsLeft());
- uint64_t v(0);
- uint64_t res(0);
-
- EXPECT_TRUE(reader.ReadBits(5, &v));
- res |= v << 19;
- EXPECT_EQ(19u, reader.BitsLeft());
- EXPECT_TRUE(reader.ReadBits(13, &v));
- res |= v << 6;
- EXPECT_EQ(6u, reader.BitsLeft());
- EXPECT_TRUE(reader.ReadBits(6, &v));
- res |= v;
- EXPECT_EQ(UINT64_C(0xd5e2af), res);
-
- EXPECT_FALSE(reader.ReadBits(1, &v));
-}
-
-TEST(BitStreamReaderTest, CanRead64Bit) {
- BitStreamReader reader(
- base::StringPiece(reinterpret_cast<const char*>(kSomeData), 8));
- EXPECT_EQ(64u, reader.BitsLeft());
- uint64_t v(0);
-
- EXPECT_TRUE(reader.ReadBits(64, &v));
- EXPECT_EQ(UINT64_C(0xd5e2afe5bb107cd1), v);
-}
-
-TEST(BitStreamReaderTest, CanReadUnaryEncodedNumbers) {
- internal::BitStreamReader reader(
- base::StringPiece(reinterpret_cast<const char*>(kSomeData), 3));
- const uint64_t expected_values[] = {2, 1, 1, 4, 0, 0, 1, 1, 1, 4};
- uint64_t v(0);
- for (int i = 0; i < 10; ++i) {
- EXPECT_TRUE(reader.ReadUnaryEncoding(&v));
- EXPECT_EQ(expected_values[i], v) << "Values differ at position " << i;
- }
-}
-
-TEST(BitStreamReaderTest, CannotReadFromEmptyStream) {
- BitStreamReader reader(base::StringPiece(
- reinterpret_cast<const char*>(kSomeData), static_cast<size_t>(0u)));
- uint64_t v(0);
-
- EXPECT_EQ(0u, reader.BitsLeft());
- EXPECT_FALSE(reader.ReadBits(1, &v));
- EXPECT_FALSE(reader.ReadUnaryEncoding(&v));
-}
-
-} // namespace internal
« no previous file with comments | « chrome/browser/net/bit_stream_reader.cc ('k') | chrome/browser/net/packed_ct_ev_whitelist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698