OLD | NEW |
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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace net { | 9 namespace net { |
10 namespace test { | 10 namespace test { |
11 namespace { | 11 namespace { |
12 | 12 |
13 TEST(QuicDataWriterTest, WriteUint8ToOffset) { | 13 TEST(QuicDataWriterTest, WriteUint8ToOffset) { |
14 QuicDataWriter writer(4); | 14 QuicDataWriter writer(4); |
15 | 15 |
| 16 writer.WriteUInt32(0xfefdfcfb); |
16 EXPECT_TRUE(writer.WriteUInt8ToOffset(1, 0)); | 17 EXPECT_TRUE(writer.WriteUInt8ToOffset(1, 0)); |
17 EXPECT_TRUE(writer.WriteUInt8ToOffset(2, 1)); | 18 EXPECT_TRUE(writer.WriteUInt8ToOffset(2, 1)); |
18 EXPECT_TRUE(writer.WriteUInt8ToOffset(3, 2)); | 19 EXPECT_TRUE(writer.WriteUInt8ToOffset(3, 2)); |
19 EXPECT_TRUE(writer.WriteUInt8ToOffset(4, 3)); | 20 EXPECT_TRUE(writer.WriteUInt8ToOffset(4, 3)); |
20 | 21 |
21 char* data = writer.take(); | 22 char* data = writer.take(); |
22 | 23 |
23 EXPECT_EQ(1, data[0]); | 24 EXPECT_EQ(1, data[0]); |
24 EXPECT_EQ(2, data[1]); | 25 EXPECT_EQ(2, data[1]); |
25 EXPECT_EQ(3, data[2]); | 26 EXPECT_EQ(3, data[2]); |
(...skipping 10 matching lines...) Expand all Loading... |
36 EXPECT_DEBUG_DEATH(writer.WriteUInt8ToOffset(5, 4), "Check failed"); | 37 EXPECT_DEBUG_DEATH(writer.WriteUInt8ToOffset(5, 4), "Check failed"); |
37 #else | 38 #else |
38 EXPECT_DEATH(writer.WriteUInt8ToOffset(5, 4), "Check failed"); | 39 EXPECT_DEATH(writer.WriteUInt8ToOffset(5, 4), "Check failed"); |
39 #endif | 40 #endif |
40 #endif | 41 #endif |
41 } | 42 } |
42 | 43 |
43 } // namespace | 44 } // namespace |
44 } // namespace test | 45 } // namespace test |
45 } // namespace net | 46 } // namespace net |
OLD | NEW |