OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/big_endian.h" |
| 6 |
5 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" |
6 #include "net/base/big_endian.h" | |
7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 | 9 |
9 namespace net { | 10 namespace base { |
10 | 11 |
11 TEST(BigEndianReaderTest, ReadsValues) { | 12 TEST(BigEndianReaderTest, ReadsValues) { |
12 char data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC }; | 13 char data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC }; |
13 char buf[2]; | 14 char buf[2]; |
14 uint8 u8; | 15 uint8 u8; |
15 uint16 u16; | 16 uint16 u16; |
16 uint32 u32; | 17 uint32 u32; |
17 base::StringPiece piece; | 18 base::StringPiece piece; |
18 BigEndianReader reader(data, sizeof(data)); | 19 BigEndianReader reader(data, sizeof(data)); |
19 | 20 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 EXPECT_TRUE(writer.Skip(2)); | 90 EXPECT_TRUE(writer.Skip(2)); |
90 // 1 left | 91 // 1 left |
91 EXPECT_FALSE(writer.WriteU16(u16)); | 92 EXPECT_FALSE(writer.WriteU16(u16)); |
92 EXPECT_FALSE(writer.WriteBytes(buf, 2)); | 93 EXPECT_FALSE(writer.WriteBytes(buf, 2)); |
93 EXPECT_TRUE(writer.Skip(1)); | 94 EXPECT_TRUE(writer.Skip(1)); |
94 // 0 left | 95 // 0 left |
95 EXPECT_FALSE(writer.WriteU8(u8)); | 96 EXPECT_FALSE(writer.WriteU8(u8)); |
96 EXPECT_EQ(0, writer.remaining()); | 97 EXPECT_EQ(0, writer.remaining()); |
97 } | 98 } |
98 | 99 |
99 } // namespace net | 100 } // namespace base |
100 | |
OLD | NEW |