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

Side by Side Diff: net/quic/quic_data_writer_test.cc

Issue 968233004: Land Recent QUIC Changes until 03/02/2015. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_data_writer.cc ('k') | net/quic/quic_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_data_writer.h" 5 #include "net/quic/quic_data_writer.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "net/quic/quic_data_reader.h" 8 #include "net/quic/quic_data_reader.h"
9 #include "net/test/gtest_util.h" 9 #include "net/test/gtest_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace net { 12 namespace net {
13 namespace test { 13 namespace test {
14 namespace { 14 namespace {
15 15
16 TEST(QuicDataWriterTest, WriteUInt8ToOffset) {
17 char buffer[4];
18 QuicDataWriter writer(4, buffer);
19
20 writer.WriteUInt32(0xfefdfcfb);
21 EXPECT_TRUE(writer.WriteUInt8ToOffset(1, 0));
22 EXPECT_TRUE(writer.WriteUInt8ToOffset(2, 1));
23 EXPECT_TRUE(writer.WriteUInt8ToOffset(3, 2));
24 EXPECT_TRUE(writer.WriteUInt8ToOffset(4, 3));
25
26 EXPECT_EQ(1, writer.data()[0]);
27 EXPECT_EQ(2, writer.data()[1]);
28 EXPECT_EQ(3, writer.data()[2]);
29 EXPECT_EQ(4, writer.data()[3]);
30 }
31
32 TEST(QuicDataWriterDeathTest, WriteUInt8ToOffset) {
33 char buffer[4];
34 QuicDataWriter writer(4, buffer);
35
36 EXPECT_DFATAL(EXPECT_FALSE(writer.WriteUInt8ToOffset(5, 4)),
37 "offset: 4 >= capacity: 4");
38 }
39
40 TEST(QuicDataWriterTest, SanityCheckUFloat16Consts) { 16 TEST(QuicDataWriterTest, SanityCheckUFloat16Consts) {
41 // Check the arithmetic on the constants - otherwise the values below make 17 // Check the arithmetic on the constants - otherwise the values below make
42 // no sense. 18 // no sense.
43 EXPECT_EQ(30, kUFloat16MaxExponent); 19 EXPECT_EQ(30, kUFloat16MaxExponent);
44 EXPECT_EQ(11, kUFloat16MantissaBits); 20 EXPECT_EQ(11, kUFloat16MantissaBits);
45 EXPECT_EQ(12, kUFloat16MantissaEffectiveBits); 21 EXPECT_EQ(12, kUFloat16MantissaEffectiveBits);
46 EXPECT_EQ(GG_UINT64_C(0x3FFC0000000), kUFloat16MaxValue); 22 EXPECT_EQ(GG_UINT64_C(0x3FFC0000000), kUFloat16MaxValue);
47 } 23 }
48 24
49 TEST(QuicDataWriterTest, WriteUFloat16) { 25 TEST(QuicDataWriterTest, WriteUFloat16) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 EXPECT_EQ(i, *reinterpret_cast<uint16*>(writer.data() + 2)); 131 EXPECT_EQ(i, *reinterpret_cast<uint16*>(writer.data() + 2));
156 // Check next decoding. 132 // Check next decoding.
157 EXPECT_EQ(i < 4096 ? i + 1 : i, 133 EXPECT_EQ(i < 4096 ? i + 1 : i,
158 *reinterpret_cast<uint16*>(writer.data() + 4)); 134 *reinterpret_cast<uint16*>(writer.data() + 4));
159 } 135 }
160 } 136 }
161 137
162 } // namespace 138 } // namespace
163 } // namespace test 139 } // namespace test
164 } // namespace net 140 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_data_writer.cc ('k') | net/quic/quic_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698