OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/quic/quic_http_utils.h" | 5 #include "net/quic/quic_http_utils.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 9 #include <limits> |
| 10 |
7 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
8 | 12 |
9 namespace net { | 13 namespace net { |
10 namespace test { | 14 namespace test { |
11 | 15 |
12 TEST(QuicHttpUtilsTest, ConvertRequestPriorityToQuicPriority) { | 16 TEST(QuicHttpUtilsTest, ConvertRequestPriorityToQuicPriority) { |
13 EXPECT_EQ(0u, ConvertRequestPriorityToQuicPriority(HIGHEST)); | 17 EXPECT_EQ(0u, ConvertRequestPriorityToQuicPriority(HIGHEST)); |
14 EXPECT_EQ(1u, ConvertRequestPriorityToQuicPriority(MEDIUM)); | 18 EXPECT_EQ(1u, ConvertRequestPriorityToQuicPriority(MEDIUM)); |
15 EXPECT_EQ(2u, ConvertRequestPriorityToQuicPriority(LOW)); | 19 EXPECT_EQ(2u, ConvertRequestPriorityToQuicPriority(LOW)); |
16 EXPECT_EQ(3u, ConvertRequestPriorityToQuicPriority(LOWEST)); | 20 EXPECT_EQ(3u, ConvertRequestPriorityToQuicPriority(LOWEST)); |
17 EXPECT_EQ(4u, ConvertRequestPriorityToQuicPriority(IDLE)); | 21 EXPECT_EQ(4u, ConvertRequestPriorityToQuicPriority(IDLE)); |
18 } | 22 } |
19 | 23 |
20 TEST(QuicHttpUtilsTest, ConvertQuicPriorityToRequestPriority) { | 24 TEST(QuicHttpUtilsTest, ConvertQuicPriorityToRequestPriority) { |
21 EXPECT_EQ(HIGHEST, ConvertQuicPriorityToRequestPriority(0)); | 25 EXPECT_EQ(HIGHEST, ConvertQuicPriorityToRequestPriority(0)); |
22 EXPECT_EQ(MEDIUM, ConvertQuicPriorityToRequestPriority(1)); | 26 EXPECT_EQ(MEDIUM, ConvertQuicPriorityToRequestPriority(1)); |
23 EXPECT_EQ(LOW, ConvertQuicPriorityToRequestPriority(2)); | 27 EXPECT_EQ(LOW, ConvertQuicPriorityToRequestPriority(2)); |
24 EXPECT_EQ(LOWEST, ConvertQuicPriorityToRequestPriority(3)); | 28 EXPECT_EQ(LOWEST, ConvertQuicPriorityToRequestPriority(3)); |
25 EXPECT_EQ(IDLE, ConvertQuicPriorityToRequestPriority(4)); | 29 EXPECT_EQ(IDLE, ConvertQuicPriorityToRequestPriority(4)); |
26 // These are invalid values, but we should still handle them | 30 // These are invalid values, but we should still handle them |
27 // gracefully. TODO(rtenneti): should we test for all possible values of | 31 // gracefully. TODO(rtenneti): should we test for all possible values of |
28 // uint32? | 32 // uint32? |
29 for (int i = 5; i < kuint8max; ++i) { | 33 for (int i = 5; i < std::numeric_limits<uint8_t>::max(); ++i) { |
30 EXPECT_EQ(IDLE, ConvertQuicPriorityToRequestPriority(i)); | 34 EXPECT_EQ(IDLE, ConvertQuicPriorityToRequestPriority(i)); |
31 } | 35 } |
32 } | 36 } |
33 | 37 |
34 } // namespace test | 38 } // namespace test |
35 } // namespace net | 39 } // namespace net |
OLD | NEW |