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

Side by Side Diff: net/spdy/spdy_frame_reader_test.cc

Issue 1471073010: Removed unused include of winsock.h/inet.h from sys_byteorder.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include inet.h for things other than byte-swap Created 5 years 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/spdy/spdy_frame_reader.cc ('k') | net/spdy/spdy_framer.cc » ('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 <algorithm> 5 #include <algorithm>
6 #include <iostream> 6 #include <iostream>
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/sys_byteorder.h" 9 #include "base/sys_byteorder.h"
10 #include "net/spdy/spdy_frame_reader.h" 10 #include "net/spdy/spdy_frame_reader.h"
11 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 TEST(SpdyFrameReaderTest, ReadUInt16) { 15 TEST(SpdyFrameReaderTest, ReadUInt16) {
16 // Frame data in network byte order. 16 // Frame data in network byte order.
17 const uint16 kFrameData[] = { 17 const uint16 kFrameData[] = {
18 htons(1), htons(1<<15), 18 base::HostToNet16(1), base::HostToNet16(1 << 15),
19 }; 19 };
20 20
21 SpdyFrameReader frame_reader(reinterpret_cast<const char*>(kFrameData), 21 SpdyFrameReader frame_reader(reinterpret_cast<const char*>(kFrameData),
22 sizeof(kFrameData)); 22 sizeof(kFrameData));
23 EXPECT_FALSE(frame_reader.IsDoneReading()); 23 EXPECT_FALSE(frame_reader.IsDoneReading());
24 24
25 uint16 uint16_val; 25 uint16 uint16_val;
26 EXPECT_TRUE(frame_reader.ReadUInt16(&uint16_val)); 26 EXPECT_TRUE(frame_reader.ReadUInt16(&uint16_val));
27 EXPECT_FALSE(frame_reader.IsDoneReading()); 27 EXPECT_FALSE(frame_reader.IsDoneReading());
28 EXPECT_EQ(1, uint16_val); 28 EXPECT_EQ(1, uint16_val);
29 29
30 EXPECT_TRUE(frame_reader.ReadUInt16(&uint16_val)); 30 EXPECT_TRUE(frame_reader.ReadUInt16(&uint16_val));
31 EXPECT_TRUE(frame_reader.IsDoneReading()); 31 EXPECT_TRUE(frame_reader.IsDoneReading());
32 EXPECT_EQ(1<<15, uint16_val); 32 EXPECT_EQ(1<<15, uint16_val);
33 } 33 }
34 34
35 TEST(SpdyFrameReaderTest, ReadUInt32) { 35 TEST(SpdyFrameReaderTest, ReadUInt32) {
36 // Frame data in network byte order. 36 // Frame data in network byte order.
37 const uint32 kFrameData[] = { 37 const uint32 kFrameData[] = {
38 htonl(1), htonl(0x80000000), 38 base::HostToNet32(1), base::HostToNet32(0x80000000),
39 }; 39 };
40 40
41 SpdyFrameReader frame_reader(reinterpret_cast<const char *>(kFrameData), 41 SpdyFrameReader frame_reader(reinterpret_cast<const char *>(kFrameData),
42 arraysize(kFrameData) * sizeof(uint32)); 42 arraysize(kFrameData) * sizeof(uint32));
43 EXPECT_FALSE(frame_reader.IsDoneReading()); 43 EXPECT_FALSE(frame_reader.IsDoneReading());
44 44
45 uint32 uint32_val; 45 uint32 uint32_val;
46 EXPECT_TRUE(frame_reader.ReadUInt32(&uint32_val)); 46 EXPECT_TRUE(frame_reader.ReadUInt32(&uint32_val));
47 EXPECT_FALSE(frame_reader.IsDoneReading()); 47 EXPECT_FALSE(frame_reader.IsDoneReading());
48 EXPECT_EQ(1u, uint32_val); 48 EXPECT_EQ(1u, uint32_val);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 SpdyFrameReader frame_reader(kFrameData, arraysize(kFrameData)); 241 SpdyFrameReader frame_reader(kFrameData, arraysize(kFrameData));
242 EXPECT_FALSE(frame_reader.IsDoneReading()); 242 EXPECT_FALSE(frame_reader.IsDoneReading());
243 243
244 char dest[arraysize(kFrameData) + 2] = {}; 244 char dest[arraysize(kFrameData) + 2] = {};
245 EXPECT_FALSE(frame_reader.ReadBytes(&dest, arraysize(kFrameData) + 1)); 245 EXPECT_FALSE(frame_reader.ReadBytes(&dest, arraysize(kFrameData) + 1));
246 EXPECT_STREQ("", dest); 246 EXPECT_STREQ("", dest);
247 } 247 }
248 248
249 } // namespace net 249 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_frame_reader.cc ('k') | net/spdy/spdy_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698