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

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

Issue 662553002: Convert ARRAYSIZE_UNSAFE -> arraysize in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months 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_auth_unittest.cc ('k') | net/http/http_cache_transaction.cc » ('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 "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;
11 int64 last_byte_position; 11 int64 last_byte_position;
12 int64 suffix_length; 12 int64 suffix_length;
13 bool valid; 13 bool valid;
14 } tests[] = { 14 } tests[] = {
15 { -1, -1, 0, false }, 15 { -1, -1, 0, false },
16 { 0, 0, 0, true }, 16 { 0, 0, 0, true },
17 { -10, 0, 0, false }, 17 { -10, 0, 0, false },
18 { 10, 0, 0, false }, 18 { 10, 0, 0, false },
19 { 10, -1, 0, true }, 19 { 10, -1, 0, true },
20 { -1, -1, -1, false }, 20 { -1, -1, -1, false },
21 { -1, 50, 0, false }, 21 { -1, 50, 0, false },
22 { 10, 10000, 0, true }, 22 { 10, 10000, 0, true },
23 { -1, -1, 100000, true }, 23 { -1, -1, 100000, true },
24 }; 24 };
25 25
26 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 26 for (size_t i = 0; i < arraysize(tests); ++i) {
27 net::HttpByteRange range; 27 net::HttpByteRange range;
28 range.set_first_byte_position(tests[i].first_byte_position); 28 range.set_first_byte_position(tests[i].first_byte_position);
29 range.set_last_byte_position(tests[i].last_byte_position); 29 range.set_last_byte_position(tests[i].last_byte_position);
30 range.set_suffix_length(tests[i].suffix_length); 30 range.set_suffix_length(tests[i].suffix_length);
31 EXPECT_EQ(tests[i].valid, range.IsValid()); 31 EXPECT_EQ(tests[i].valid, range.IsValid());
32 } 32 }
33 } 33 }
34 34
35 TEST(HttpByteRangeTest, SetInstanceSize) { 35 TEST(HttpByteRangeTest, SetInstanceSize) {
36 const struct { 36 const struct {
(...skipping 11 matching lines...) Expand all
48 { -1, -1, -1, 0, true, 0, -1 }, 48 { -1, -1, -1, 0, true, 0, -1 },
49 { -1, -1, 500, 0, true, 0, -1 }, 49 { -1, -1, 500, 0, true, 0, -1 },
50 { -1, 50, -1, 0, false, -1, -1 }, 50 { -1, 50, -1, 0, false, -1, -1 },
51 { -1, -1, 500, 300, true, 0, 299 }, 51 { -1, -1, 500, 300, true, 0, 299 },
52 { -1, -1, -1, 100, true, 0, 99 }, 52 { -1, -1, -1, 100, true, 0, 99 },
53 { 10, -1, -1, 100, true, 10, 99 }, 53 { 10, -1, -1, 100, true, 10, 99 },
54 { -1, -1, 500, 1000, true, 500, 999 }, 54 { -1, -1, 500, 1000, true, 500, 999 },
55 { 10, 10000, -1, 1000000, true, 10, 10000 }, 55 { 10, 10000, -1, 1000000, true, 10, 10000 },
56 }; 56 };
57 57
58 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 58 for (size_t i = 0; i < arraysize(tests); ++i) {
59 net::HttpByteRange range; 59 net::HttpByteRange range;
60 range.set_first_byte_position(tests[i].first_byte_position); 60 range.set_first_byte_position(tests[i].first_byte_position);
61 range.set_last_byte_position(tests[i].last_byte_position); 61 range.set_last_byte_position(tests[i].last_byte_position);
62 range.set_suffix_length(tests[i].suffix_length); 62 range.set_suffix_length(tests[i].suffix_length);
63 63
64 bool return_value = range.ComputeBounds(tests[i].instance_size); 64 bool return_value = range.ComputeBounds(tests[i].instance_size);
65 EXPECT_EQ(tests[i].expected_return_value, return_value); 65 EXPECT_EQ(tests[i].expected_return_value, return_value);
66 if (return_value) { 66 if (return_value) {
67 EXPECT_EQ(tests[i].expected_lower_bound, range.first_byte_position()); 67 EXPECT_EQ(tests[i].expected_lower_bound, range.first_byte_position());
68 EXPECT_EQ(tests[i].expected_upper_bound, range.last_byte_position()); 68 EXPECT_EQ(tests[i].expected_upper_bound, range.last_byte_position());
(...skipping 10 matching lines...) Expand all
79 79
80 TEST(HttpByteRangeTest, GetHeaderValue) { 80 TEST(HttpByteRangeTest, GetHeaderValue) {
81 static const struct { 81 static const struct {
82 net::HttpByteRange range; 82 net::HttpByteRange range;
83 const char* expected; 83 const char* expected;
84 } tests[] = {{net::HttpByteRange::Bounded(0, 0), "bytes=0-0"}, 84 } tests[] = {{net::HttpByteRange::Bounded(0, 0), "bytes=0-0"},
85 {net::HttpByteRange::Bounded(0, 100), "bytes=0-100"}, 85 {net::HttpByteRange::Bounded(0, 100), "bytes=0-100"},
86 {net::HttpByteRange::Bounded(0, -1), "bytes=0-"}, 86 {net::HttpByteRange::Bounded(0, -1), "bytes=0-"},
87 {net::HttpByteRange::RightUnbounded(100), "bytes=100-"}, 87 {net::HttpByteRange::RightUnbounded(100), "bytes=100-"},
88 {net::HttpByteRange::Suffix(100), "bytes=-100"}, }; 88 {net::HttpByteRange::Suffix(100), "bytes=-100"}, };
89 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 89 for (size_t i = 0; i < arraysize(tests); ++i) {
90 EXPECT_EQ(tests[i].expected, tests[i].range.GetHeaderValue()); 90 EXPECT_EQ(tests[i].expected, tests[i].range.GetHeaderValue());
91 } 91 }
92 } 92 }
OLDNEW
« no previous file with comments | « net/http/http_auth_unittest.cc ('k') | net/http/http_cache_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698