| OLD | NEW |
| 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 // Common utilities for Quic tests | 5 // Common utilities for Quic tests |
| 6 | 6 |
| 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 // underflow. | 1040 // underflow. |
| 1041 ASSERT_LE(relative_margin, 1); | 1041 ASSERT_LE(relative_margin, 1); |
| 1042 ASSERT_GE(relative_margin, 0); | 1042 ASSERT_GE(relative_margin, 0); |
| 1043 | 1043 |
| 1044 T absolute_margin = expected * relative_margin; | 1044 T absolute_margin = expected * relative_margin; |
| 1045 | 1045 |
| 1046 EXPECT_GE(expected + absolute_margin, actual); | 1046 EXPECT_GE(expected + absolute_margin, actual); |
| 1047 EXPECT_LE(expected - absolute_margin, actual); | 1047 EXPECT_LE(expected - absolute_margin, actual); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 template <typename T> |
| 1051 QuicHeaderList AsHeaderList(const T& container) { |
| 1052 QuicHeaderList l; |
| 1053 l.OnHeaderBlockStart(); |
| 1054 size_t total_size = 0; |
| 1055 for (auto p : container) { |
| 1056 total_size += p.first.size() + p.second.size(); |
| 1057 l.OnHeader(p.first, p.second); |
| 1058 } |
| 1059 l.OnHeaderBlockEnd(total_size); |
| 1060 return l; |
| 1061 } |
| 1062 |
| 1050 } // namespace test | 1063 } // namespace test |
| 1051 } // namespace net | 1064 } // namespace net |
| 1052 | 1065 |
| 1053 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 1066 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |