Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: net/http/http_byte_range_unittest.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_byte_range.cc ('k') | net/http/http_cache.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/macros.h"
5 #include "net/http/http_byte_range.h" 6 #include "net/http/http_byte_range.h"
6 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
7 8
8 namespace net { 9 namespace net {
9 10
10 namespace { 11 namespace {
11 12
12 TEST(HttpByteRangeTest, ValidRanges) { 13 TEST(HttpByteRangeTest, ValidRanges) {
13 const struct { 14 const struct {
14 int64 first_byte_position; 15 int64_t first_byte_position;
15 int64 last_byte_position; 16 int64_t last_byte_position;
16 int64 suffix_length; 17 int64_t suffix_length;
17 bool valid; 18 bool valid;
18 } tests[] = { 19 } tests[] = {
19 { -1, -1, 0, false }, 20 { -1, -1, 0, false },
20 { 0, 0, 0, true }, 21 { 0, 0, 0, true },
21 { -10, 0, 0, false }, 22 { -10, 0, 0, false },
22 { 10, 0, 0, false }, 23 { 10, 0, 0, false },
23 { 10, -1, 0, true }, 24 { 10, -1, 0, true },
24 { -1, -1, -1, false }, 25 { -1, -1, -1, false },
25 { -1, 50, 0, false }, 26 { -1, 50, 0, false },
26 { 10, 10000, 0, true }, 27 { 10, 10000, 0, true },
27 { -1, -1, 100000, true }, 28 { -1, -1, 100000, true },
28 }; 29 };
29 30
30 for (size_t i = 0; i < arraysize(tests); ++i) { 31 for (size_t i = 0; i < arraysize(tests); ++i) {
31 HttpByteRange range; 32 HttpByteRange range;
32 range.set_first_byte_position(tests[i].first_byte_position); 33 range.set_first_byte_position(tests[i].first_byte_position);
33 range.set_last_byte_position(tests[i].last_byte_position); 34 range.set_last_byte_position(tests[i].last_byte_position);
34 range.set_suffix_length(tests[i].suffix_length); 35 range.set_suffix_length(tests[i].suffix_length);
35 EXPECT_EQ(tests[i].valid, range.IsValid()); 36 EXPECT_EQ(tests[i].valid, range.IsValid());
36 } 37 }
37 } 38 }
38 39
39 TEST(HttpByteRangeTest, SetInstanceSize) { 40 TEST(HttpByteRangeTest, SetInstanceSize) {
40 const struct { 41 const struct {
41 int64 first_byte_position; 42 int64_t first_byte_position;
42 int64 last_byte_position; 43 int64_t last_byte_position;
43 int64 suffix_length; 44 int64_t suffix_length;
44 int64 instance_size; 45 int64_t instance_size;
45 bool expected_return_value; 46 bool expected_return_value;
46 int64 expected_lower_bound; 47 int64_t expected_lower_bound;
47 int64 expected_upper_bound; 48 int64_t expected_upper_bound;
48 } tests[] = { 49 } tests[] = {
49 { -10, 0, -1, 0, false, -1, -1 }, 50 { -10, 0, -1, 0, false, -1, -1 },
50 { 10, 0, -1, 0, false, -1, -1 }, 51 { 10, 0, -1, 0, false, -1, -1 },
51 // Zero instance size is valid, this is the case that user has to handle. 52 // Zero instance size is valid, this is the case that user has to handle.
52 { -1, -1, -1, 0, true, 0, -1 }, 53 { -1, -1, -1, 0, true, 0, -1 },
53 { -1, -1, 500, 0, true, 0, -1 }, 54 { -1, -1, 500, 0, true, 0, -1 },
54 { -1, 50, -1, 0, false, -1, -1 }, 55 { -1, 50, -1, 0, false, -1, -1 },
55 { -1, -1, 500, 300, true, 0, 299 }, 56 { -1, -1, 500, 300, true, 0, 299 },
56 { -1, -1, -1, 100, true, 0, 99 }, 57 { -1, -1, -1, 100, true, 0, 99 },
57 { 10, -1, -1, 100, true, 10, 99 }, 58 { 10, -1, -1, 100, true, 10, 99 },
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 {HttpByteRange::Suffix(100), "bytes=-100"}, 94 {HttpByteRange::Suffix(100), "bytes=-100"},
94 }; 95 };
95 for (size_t i = 0; i < arraysize(tests); ++i) { 96 for (size_t i = 0; i < arraysize(tests); ++i) {
96 EXPECT_EQ(tests[i].expected, tests[i].range.GetHeaderValue()); 97 EXPECT_EQ(tests[i].expected, tests[i].range.GetHeaderValue());
97 } 98 }
98 } 99 }
99 100
100 } // namespace 101 } // namespace
101 102
102 } // namespace net 103 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_byte_range.cc ('k') | net/http/http_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698