| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/spdy/hpack/hpack_output_stream.h" | 5 #include "net/spdy/hpack/hpack_output_stream.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 10 |
| 12 namespace net { | 11 namespace net { |
| 13 | 12 |
| 14 namespace { | 13 namespace { |
| 15 | 14 |
| 16 using std::string; | 15 using std::string; |
| 17 | 16 |
| 18 // Make sure that AppendBits() appends bits starting from the most | 17 // Make sure that AppendBits() appends bits starting from the most |
| 19 // significant bit, and that it can handle crossing a byte boundary. | 18 // significant bit, and that it can handle crossing a byte boundary. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 40 | 39 |
| 41 output_stream.AppendBits(0x0, 7); | 40 output_stream.AppendBits(0x0, 7); |
| 42 | 41 |
| 43 string str; | 42 string str; |
| 44 output_stream.TakeString(&str); | 43 output_stream.TakeString(&str); |
| 45 EXPECT_EQ(expected_str, str); | 44 EXPECT_EQ(expected_str, str); |
| 46 } | 45 } |
| 47 | 46 |
| 48 // Utility function to return I as a string encoded with an N-bit | 47 // Utility function to return I as a string encoded with an N-bit |
| 49 // prefix. | 48 // prefix. |
| 50 string EncodeUint32(uint8 N, uint32 I) { | 49 string EncodeUint32(uint8_t N, uint32_t I) { |
| 51 HpackOutputStream output_stream; | 50 HpackOutputStream output_stream; |
| 52 if (N < 8) { | 51 if (N < 8) { |
| 53 output_stream.AppendBits(0x00, 8 - N); | 52 output_stream.AppendBits(0x00, 8 - N); |
| 54 } | 53 } |
| 55 output_stream.AppendUint32(I); | 54 output_stream.AppendUint32(I); |
| 56 string str; | 55 string str; |
| 57 output_stream.TakeString(&str); | 56 output_stream.TakeString(&str); |
| 58 return str; | 57 return str; |
| 59 } | 58 } |
| 60 | 59 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 output_stream.AppendBytes("buffer2"); | 250 output_stream.AppendBytes("buffer2"); |
| 252 | 251 |
| 253 string str; | 252 string str; |
| 254 output_stream.TakeString(&str); | 253 output_stream.TakeString(&str); |
| 255 EXPECT_EQ("buffer1buffer2", str); | 254 EXPECT_EQ("buffer1buffer2", str); |
| 256 } | 255 } |
| 257 | 256 |
| 258 } // namespace | 257 } // namespace |
| 259 | 258 |
| 260 } // namespace net | 259 } // namespace net |
| OLD | NEW |