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/spdy_prefixed_buffer_reader.h" | 5 #include "net/spdy/spdy_prefixed_buffer_reader.h" |
6 | 6 |
7 #include "testing/gmock/include/gmock/gmock.h" | 7 #include "testing/gmock/include/gmock/gmock.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 | 11 |
12 namespace test { | 12 namespace test { |
13 | 13 |
14 using base::StringPiece; | 14 using base::StringPiece; |
15 using testing::ElementsAreArray; | 15 using testing::ElementsAreArray; |
16 | 16 |
17 class SpdyPrefixedBufferReaderTest : public ::testing::Test { | 17 class SpdyPrefixedBufferReaderTest : public ::testing::Test { |
18 protected: | 18 protected: |
19 SpdyPrefixedBufferReader Build(std::string prefix, std::string suffix) { | 19 SpdyPrefixedBufferReader Build(std::string prefix, std::string suffix) { |
20 prefix_ = prefix; | 20 prefix_ = prefix; |
21 suffix_ = suffix; | 21 suffix_ = suffix; |
22 return SpdyPrefixedBufferReader(prefix_.data(), prefix_.length(), | 22 return SpdyPrefixedBufferReader( |
23 suffix_.data(), suffix_.length()); | 23 prefix_.data(), prefix_.length(), suffix_.data(), suffix_.length()); |
24 } | 24 } |
25 std::string prefix_, suffix_; | 25 std::string prefix_, suffix_; |
26 }; | 26 }; |
27 | 27 |
28 TEST_F(SpdyPrefixedBufferReaderTest, ReadRawFromPrefix) { | 28 TEST_F(SpdyPrefixedBufferReaderTest, ReadRawFromPrefix) { |
29 SpdyPrefixedBufferReader reader = Build("foobar", ""); | 29 SpdyPrefixedBufferReader reader = Build("foobar", ""); |
30 EXPECT_EQ(6u, reader.Available()); | 30 EXPECT_EQ(6u, reader.Available()); |
31 | 31 |
32 char buffer[] = "123456"; | 32 char buffer[] = "123456"; |
33 EXPECT_FALSE(reader.ReadN(10, buffer)); // Not enough buffer. | 33 EXPECT_FALSE(reader.ReadN(10, buffer)); // Not enough buffer. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 EXPECT_EQ(1u, reader.Available()); | 120 EXPECT_EQ(1u, reader.Available()); |
121 | 121 |
122 EXPECT_TRUE(reader.ReadN(1, buffer)); | 122 EXPECT_TRUE(reader.ReadN(1, buffer)); |
123 EXPECT_THAT(buffer, ElementsAreArray("lec4")); | 123 EXPECT_THAT(buffer, ElementsAreArray("lec4")); |
124 EXPECT_EQ(0u, reader.Available()); | 124 EXPECT_EQ(0u, reader.Available()); |
125 } | 125 } |
126 | 126 |
127 } // namespace test | 127 } // namespace test |
128 | 128 |
129 } // namespace net | 129 } // namespace net |
OLD | NEW |