OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/http2/http2_structures.h" | 5 #include "net/http2/http2_structures.h" |
6 | 6 |
7 // Tests are focused on Http2FrameHeader because it has by far the most | 7 // Tests are focused on Http2FrameHeader because it has by far the most |
8 // methods of any of the structures. | 8 // methods of any of the structures. |
9 // Note that EXPECT.*DEATH tests are slow (a fork is probably involved). | 9 // Note that EXPECT.*DEATH tests are slow (a fork is probably involved). |
10 | 10 |
11 // And in case you're wondering, yes, these are ridiculously thorough tests, | 11 // And in case you're wondering, yes, these are ridiculously thorough tests, |
12 // but believe it or not, I've found stupid bugs this way. | 12 // but believe it or not, I've found stupid bugs this way. |
13 | 13 |
14 #include <memory> | 14 #include <memory> |
15 #include <ostream> | 15 #include <ostream> |
16 #include <sstream> | 16 #include <sstream> |
17 #include <tuple> | 17 #include <tuple> |
18 #include <type_traits> | 18 #include <type_traits> |
19 #include <vector> | 19 #include <vector> |
20 | 20 |
21 #include "base/template_util.h" | |
22 #include "net/http2/http2_structures_test_util.h" | 21 #include "net/http2/http2_structures_test_util.h" |
23 #include "net/http2/tools/failure.h" | 22 #include "net/http2/tools/failure.h" |
24 #include "net/http2/tools/http2_random.h" | 23 #include "net/http2/tools/http2_random.h" |
25 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
27 | 26 |
28 using ::testing::AssertionResult; | 27 using ::testing::AssertionResult; |
29 using ::testing::AssertionSuccess; | 28 using ::testing::AssertionSuccess; |
30 using ::testing::Combine; | 29 using ::testing::Combine; |
31 using ::testing::EndsWith; | 30 using ::testing::EndsWith; |
32 using ::testing::HasSubstr; | 31 using ::testing::HasSubstr; |
33 using ::testing::MatchesRegex; | 32 using ::testing::MatchesRegex; |
34 using ::testing::Not; | 33 using ::testing::Not; |
35 using ::testing::Values; | 34 using ::testing::Values; |
36 using ::testing::ValuesIn; | 35 using ::testing::ValuesIn; |
37 using std::string; | 36 using std::string; |
38 | 37 |
39 namespace net { | 38 namespace net { |
40 namespace test { | 39 namespace test { |
41 namespace { | 40 namespace { |
42 | 41 |
43 template <typename E> | 42 template <typename E> |
44 E IncrementEnum(E e) { | 43 E IncrementEnum(E e) { |
45 typedef typename base::underlying_type<E>::type I; | 44 using I = typename std::underlying_type<E>::type; |
46 return static_cast<E>(1 + static_cast<I>(e)); | 45 return static_cast<E>(1 + static_cast<I>(e)); |
47 } | 46 } |
48 | 47 |
49 #if GTEST_HAS_DEATH_TEST && !defined(NDEBUG) | 48 #if GTEST_HAS_DEATH_TEST && !defined(NDEBUG) |
50 std::vector<Http2FrameType> ValidFrameTypes() { | 49 std::vector<Http2FrameType> ValidFrameTypes() { |
51 std::vector<Http2FrameType> valid_types{Http2FrameType::DATA}; | 50 std::vector<Http2FrameType> valid_types{Http2FrameType::DATA}; |
52 while (valid_types.back() != Http2FrameType::ALTSVC) { | 51 while (valid_types.back() != Http2FrameType::ALTSVC) { |
53 valid_types.push_back(IncrementEnum(valid_types.back())); | 52 valid_types.push_back(IncrementEnum(valid_types.back())); |
54 } | 53 } |
55 return valid_types; | 54 return valid_types; |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 EXPECT_EQ(w, w); | 482 EXPECT_EQ(w, w); |
484 EXPECT_NE(v, w); | 483 EXPECT_NE(v, w); |
485 | 484 |
486 v.origin_length = w.origin_length; | 485 v.origin_length = w.origin_length; |
487 EXPECT_EQ(v, w); | 486 EXPECT_EQ(v, w); |
488 } | 487 } |
489 | 488 |
490 } // namespace | 489 } // namespace |
491 } // namespace test | 490 } // namespace test |
492 } // namespace net | 491 } // namespace net |
OLD | NEW |