OLD | NEW |
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 29 matching lines...) Expand all Loading... |
40 EXPECT_EQ(0, stream.GetBytesBuffer(buf, sizeof(buf))); | 40 EXPECT_EQ(0, stream.GetBytesBuffer(buf, sizeof(buf))); |
41 ExpectBufferSet(buf, '!', sizeof(buf)); | 41 ExpectBufferSet(buf, '!', sizeof(buf)); |
42 } | 42 } |
43 | 43 |
44 TEST(StringHTTPBodyStream, SmallString) { | 44 TEST(StringHTTPBodyStream, SmallString) { |
45 uint8_t buf[32]; | 45 uint8_t buf[32]; |
46 memset(buf, '!', sizeof(buf)); | 46 memset(buf, '!', sizeof(buf)); |
47 | 47 |
48 std::string string("Hello, world"); | 48 std::string string("Hello, world"); |
49 StringHTTPBodyStream stream(string); | 49 StringHTTPBodyStream stream(string); |
50 EXPECT_EQ(implicit_cast<ssize_t>(string.length()), | 50 EXPECT_EQ(implicit_cast<FileOperationResult>(string.length()), |
51 stream.GetBytesBuffer(buf, sizeof(buf))); | 51 stream.GetBytesBuffer(buf, sizeof(buf))); |
52 | 52 |
53 std::string actual(reinterpret_cast<const char*>(buf), string.length()); | 53 std::string actual(reinterpret_cast<const char*>(buf), string.length()); |
54 EXPECT_EQ(string, actual); | 54 EXPECT_EQ(string, actual); |
55 ExpectBufferSet(buf + string.length(), '!', sizeof(buf) - string.length()); | 55 ExpectBufferSet(buf + string.length(), '!', sizeof(buf) - string.length()); |
56 | 56 |
57 EXPECT_EQ(0, stream.GetBytesBuffer(buf, sizeof(buf))); | 57 EXPECT_EQ(0, stream.GetBytesBuffer(buf, sizeof(buf))); |
58 } | 58 } |
59 | 59 |
60 TEST(StringHTTPBodyStream, MultipleReads) { | 60 TEST(StringHTTPBodyStream, MultipleReads) { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 EXPECT_EQ(expected_string, actual_string); | 209 EXPECT_EQ(expected_string, actual_string); |
210 } | 210 } |
211 | 211 |
212 INSTANTIATE_TEST_CASE_P(VariableBufferSize, | 212 INSTANTIATE_TEST_CASE_P(VariableBufferSize, |
213 CompositeHTTPBodyStreamBufferSize, | 213 CompositeHTTPBodyStreamBufferSize, |
214 testing::Values(1, 2, 9, 16, 31, 128, 1024)); | 214 testing::Values(1, 2, 9, 16, 31, 128, 1024)); |
215 | 215 |
216 } // namespace | 216 } // namespace |
217 } // namespace test | 217 } // namespace test |
218 } // namespace crashpad | 218 } // namespace crashpad |
OLD | NEW |