| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/http/http_byte_range.h" | 5 #include "net/http/http_byte_range.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 TEST(HttpByteRangeTest, ValidRanges) { | 8 TEST(HttpByteRangeTest, ValidRanges) { |
| 9 const struct { | 9 const struct { |
| 10 int64 first_byte_position; | 10 int64 first_byte_position; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 // Try to call SetInstanceSize the second time. | 70 // Try to call SetInstanceSize the second time. |
| 71 EXPECT_FALSE(range.ComputeBounds(tests[i].instance_size)); | 71 EXPECT_FALSE(range.ComputeBounds(tests[i].instance_size)); |
| 72 // And expect there's no side effect. | 72 // And expect there's no side effect. |
| 73 EXPECT_EQ(tests[i].expected_lower_bound, range.first_byte_position()); | 73 EXPECT_EQ(tests[i].expected_lower_bound, range.first_byte_position()); |
| 74 EXPECT_EQ(tests[i].expected_upper_bound, range.last_byte_position()); | 74 EXPECT_EQ(tests[i].expected_upper_bound, range.last_byte_position()); |
| 75 EXPECT_EQ(tests[i].suffix_length, range.suffix_length()); | 75 EXPECT_EQ(tests[i].suffix_length, range.suffix_length()); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 |
| 80 TEST(HttpByteRangeTest, GetHeaderValue) { |
| 81 static const struct { |
| 82 net::HttpByteRange range; |
| 83 const char* expected; |
| 84 } tests[] = {{net::HttpByteRange::Bounded(0, 0), "bytes=0-0"}, |
| 85 {net::HttpByteRange::Bounded(0, 100), "bytes=0-100"}, |
| 86 {net::HttpByteRange::Bounded(0, -1), "bytes=0-"}, |
| 87 {net::HttpByteRange::RightUnbounded(100), "bytes=100-"}, |
| 88 {net::HttpByteRange::Suffix(100), "bytes=-100"}, }; |
| 89 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 90 EXPECT_EQ(tests[i].expected, tests[i].range.GetHeaderValue()); |
| 91 } |
| 92 } |
| OLD | NEW |