| 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 #include <algorithm> | 5 #include <algorithm> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "net/http/http_util.h" | 9 #include "net/http/http_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 {"", false, -1, -1, -1}, | 975 {"", false, -1, -1, -1}, |
| 976 {"megabytes 0-10/50", false, -1, -1, -1}, | 976 {"megabytes 0-10/50", false, -1, -1, -1}, |
| 977 {"0-10/50", false, -1, -1, -1}, | 977 {"0-10/50", false, -1, -1, -1}, |
| 978 {"Bytes 0-50/51", true, 0, 50, 51}, | 978 {"Bytes 0-50/51", true, 0, 50, 51}, |
| 979 {"bytes 0-50/51", true, 0, 50, 51}, | 979 {"bytes 0-50/51", true, 0, 50, 51}, |
| 980 {"bytes\t0-50/51", false, -1, -1, -1}, | 980 {"bytes\t0-50/51", false, -1, -1, -1}, |
| 981 {" bytes 0-50/51", true, 0, 50, 51}, | 981 {" bytes 0-50/51", true, 0, 50, 51}, |
| 982 {" bytes 0 - 50 \t / \t51", true, 0, 50, 51}, | 982 {" bytes 0 - 50 \t / \t51", true, 0, 50, 51}, |
| 983 {"bytes 0\t-\t50\t/\t51\t", true, 0, 50, 51}, | 983 {"bytes 0\t-\t50\t/\t51\t", true, 0, 50, 51}, |
| 984 {" \tbytes\t\t\t 0\t-\t50\t/\t51\t", true, 0, 50, 51}, | 984 {" \tbytes\t\t\t 0\t-\t50\t/\t51\t", true, 0, 50, 51}, |
| 985 {"\t bytes \t 0 - 50 / 5 1", false, 0, 50, -1}, | 985 {"\t bytes \t 0 - 50 / 5 1", false, -1, -1, -1}, |
| 986 {"\t bytes \t 0 - 5 0 / 51", false, -1, -1, -1}, | 986 {"\t bytes \t 0 - 5 0 / 51", false, -1, -1, -1}, |
| 987 {"bytes 50-0/51", false, 50, 0, -1}, | 987 {"bytes 50-0/51", false, -1, -1, -1}, |
| 988 {"bytes * /*", false, -1, -1, -1}, | 988 {"bytes * /*", false, -1, -1, -1}, |
| 989 {"bytes * / * ", false, -1, -1, -1}, | 989 {"bytes * / * ", false, -1, -1, -1}, |
| 990 {"bytes 0-50/*", false, 0, 50, -1}, | 990 {"bytes 0-50/*", false, -1, -1, -1}, |
| 991 {"bytes 0-50 / * ", false, 0, 50, -1}, | 991 {"bytes 0-50 / * ", false, -1, -1, -1}, |
| 992 {"bytes 0-10000000000/10000000001", true, 0, 10000000000ll, | 992 {"bytes 0-10000000000/10000000001", true, 0, 10000000000ll, |
| 993 10000000001ll}, | 993 10000000001ll}, |
| 994 {"bytes 0-10000000000/10000000000", false, 0, 10000000000ll, | 994 {"bytes 0-10000000000/10000000000", false, -1, -1, -1}, |
| 995 10000000000ll}, | |
| 996 // 64 bit wraparound. | 995 // 64 bit wraparound. |
| 997 {"bytes 0 - 9223372036854775807 / 100", false, 0, | 996 {"bytes 0 - 9223372036854775807 / 100", false, -1, -1, -1}, |
| 998 std::numeric_limits<int64_t>::max(), 100}, | |
| 999 // 64 bit wraparound. | 997 // 64 bit wraparound. |
| 1000 {"bytes 0 - 100 / -9223372036854775808", false, 0, 100, | 998 {"bytes 0 - 100 / -9223372036854775808", false, -1, -1, -1}, |
| 1001 std::numeric_limits<int64_t>::min()}, | 999 {"bytes */50", false, -1, -1, -1}, |
| 1002 {"bytes */50", false, -1, -1, 50}, | 1000 {"bytes 0-50/10", false, -1, -1, -1}, |
| 1003 {"bytes 0-50/10", false, 0, 50, 10}, | 1001 {"bytes 40-50/45", false, -1, -1, -1}, |
| 1004 {"bytes 40-50/45", false, 40, 50, 45}, | 1002 {"bytes 0-50/-10", false, -1, -1, -1}, |
| 1005 {"bytes 0-50/-10", false, 0, 50, -10}, | |
| 1006 {"bytes 0-0/1", true, 0, 0, 1}, | 1003 {"bytes 0-0/1", true, 0, 0, 1}, |
| 1007 {"bytes 0-40000000000000000000/40000000000000000001", false, -1, -1, -1}, | 1004 {"bytes 0-40000000000000000000/40000000000000000001", false, -1, -1, -1}, |
| 1008 {"bytes 1-/100", false, -1, -1, -1}, | 1005 {"bytes 1-/100", false, -1, -1, -1}, |
| 1009 {"bytes -/100", false, -1, -1, -1}, | 1006 {"bytes -/100", false, -1, -1, -1}, |
| 1010 {"bytes -1/100", false, -1, -1, -1}, | 1007 {"bytes -1/100", false, -1, -1, -1}, |
| 1011 {"bytes 0-1233/*", false, 0, 1233, -1}, | 1008 {"bytes 0-1233/*", false, -1, -1, -1}, |
| 1012 {"bytes -123 - -1/100", false, -1, -1, -1}, | 1009 {"bytes -123 - -1/100", false, -1, -1, -1}, |
| 1013 }; | 1010 }; |
| 1014 | 1011 |
| 1015 for (const auto& test : tests) { | 1012 for (const auto& test : tests) { |
| 1016 int64_t first_byte_position, last_byte_position, instance_length; | 1013 int64_t first_byte_position, last_byte_position, instance_length; |
| 1017 EXPECT_EQ(test.expected_return_value, | 1014 EXPECT_EQ(test.expected_return_value, |
| 1018 HttpUtil::ParseContentRangeHeader( | 1015 HttpUtil::ParseContentRangeHeader( |
| 1019 test.content_range_header_spec, &first_byte_position, | 1016 test.content_range_header_spec, &first_byte_position, |
| 1020 &last_byte_position, &instance_length)) | 1017 &last_byte_position, &instance_length)) |
| 1021 << test.content_range_header_spec; | 1018 << test.content_range_header_spec; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 EXPECT_FALSE(HttpUtil::IsToken("hello, world")); | 1464 EXPECT_FALSE(HttpUtil::IsToken("hello, world")); |
| 1468 EXPECT_FALSE(HttpUtil::IsToken(" ")); | 1465 EXPECT_FALSE(HttpUtil::IsToken(" ")); |
| 1469 EXPECT_FALSE(HttpUtil::IsToken(base::StringPiece("\0", 1))); | 1466 EXPECT_FALSE(HttpUtil::IsToken(base::StringPiece("\0", 1))); |
| 1470 EXPECT_FALSE(HttpUtil::IsToken("\x01")); | 1467 EXPECT_FALSE(HttpUtil::IsToken("\x01")); |
| 1471 EXPECT_FALSE(HttpUtil::IsToken("\x7F")); | 1468 EXPECT_FALSE(HttpUtil::IsToken("\x7F")); |
| 1472 EXPECT_FALSE(HttpUtil::IsToken("\x80")); | 1469 EXPECT_FALSE(HttpUtil::IsToken("\x80")); |
| 1473 EXPECT_FALSE(HttpUtil::IsToken("\xff")); | 1470 EXPECT_FALSE(HttpUtil::IsToken("\xff")); |
| 1474 } | 1471 } |
| 1475 | 1472 |
| 1476 } // namespace net | 1473 } // namespace net |
| OLD | NEW |