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

Side by Side Diff: util/numeric/checked_range_test.cc

Issue 849193002: win: Some %zu to PRIuS (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fix include order Created 5 years, 11 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 | « util/misc/uuid_test.cc ('k') | util/stdlib/strlcpy_test.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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/numeric/checked_range.h" 15 #include "util/numeric/checked_range.h"
16 16
17 #include <stdint.h> 17 #include <stdint.h>
18 18
19 #include <limits> 19 #include <limits>
20 20
21 #include "base/basictypes.h" 21 #include "base/basictypes.h"
22 #include "base/format_macros.h"
22 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
23 #include "gtest/gtest.h" 24 #include "gtest/gtest.h"
24 25
25 namespace crashpad { 26 namespace crashpad {
26 namespace test { 27 namespace test {
27 namespace { 28 namespace {
28 29
29 TEST(CheckedRange, IsValid) { 30 TEST(CheckedRange, IsValid) {
30 const struct UnsignedTestData { 31 const struct UnsignedTestData {
31 uint32_t base; 32 uint32_t base;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 {0xffffffff, 1, false}, 72 {0xffffffff, 1, false},
72 {0xffffffff, 2, false}, 73 {0xffffffff, 2, false},
73 {0xffffffff, 0x7fffffff, false}, 74 {0xffffffff, 0x7fffffff, false},
74 {0xffffffff, 0x80000000, false}, 75 {0xffffffff, 0x80000000, false},
75 {0xffffffff, 0xfffffffe, false}, 76 {0xffffffff, 0xfffffffe, false},
76 {0xffffffff, 0xffffffff, false}, 77 {0xffffffff, 0xffffffff, false},
77 }; 78 };
78 79
79 for (size_t index = 0; index < arraysize(kUnsignedTestData); ++index) { 80 for (size_t index = 0; index < arraysize(kUnsignedTestData); ++index) {
80 const UnsignedTestData& testcase = kUnsignedTestData[index]; 81 const UnsignedTestData& testcase = kUnsignedTestData[index];
81 SCOPED_TRACE(base::StringPrintf("unsigned index %zu, base 0x%x, size 0x%x", 82 SCOPED_TRACE(base::StringPrintf("unsigned index %" PRIuS
83 ", base 0x%x, size 0x%x",
82 index, 84 index,
83 testcase.base, 85 testcase.base,
84 testcase.size)); 86 testcase.size));
85 87
86 CheckedRange<uint32_t> range(testcase.base, testcase.size); 88 CheckedRange<uint32_t> range(testcase.base, testcase.size);
87 EXPECT_EQ(testcase.valid, range.IsValid()); 89 EXPECT_EQ(testcase.valid, range.IsValid());
88 } 90 }
89 91
90 const int32_t kMinInt32 = std::numeric_limits<int32_t>::min(); 92 const int32_t kMinInt32 = std::numeric_limits<int32_t>::min();
91 const struct SignedTestData { 93 const struct SignedTestData {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 {-1, 1, true}, 134 {-1, 1, true},
133 {-1, 2, true}, 135 {-1, 2, true},
134 {-1, 0x7fffffff, true}, 136 {-1, 0x7fffffff, true},
135 {-1, 0x80000000, false}, 137 {-1, 0x80000000, false},
136 {-1, 0xfffffffe, false}, 138 {-1, 0xfffffffe, false},
137 {-1, 0xffffffff, false}, 139 {-1, 0xffffffff, false},
138 }; 140 };
139 141
140 for (size_t index = 0; index < arraysize(kSignedTestData); ++index) { 142 for (size_t index = 0; index < arraysize(kSignedTestData); ++index) {
141 const SignedTestData& testcase = kSignedTestData[index]; 143 const SignedTestData& testcase = kSignedTestData[index];
142 SCOPED_TRACE(base::StringPrintf("signed index %zu, base 0x%x, size 0x%x", 144 SCOPED_TRACE(base::StringPrintf("signed index %" PRIuS
145 ", base 0x%x, size 0x%x",
143 index, 146 index,
144 testcase.base, 147 testcase.base,
145 testcase.size)); 148 testcase.size));
146 149
147 CheckedRange<int32_t, uint32_t> range(testcase.base, testcase.size); 150 CheckedRange<int32_t, uint32_t> range(testcase.base, testcase.size);
148 EXPECT_EQ(testcase.valid, range.IsValid()); 151 EXPECT_EQ(testcase.valid, range.IsValid());
149 } 152 }
150 } 153 }
151 154
152 TEST(CheckedRange, ContainsValue) { 155 TEST(CheckedRange, ContainsValue) {
(...skipping 24 matching lines...) Expand all
177 {0xffffdfff, false}, 180 {0xffffdfff, false},
178 {0xffffefff, false}, 181 {0xffffefff, false},
179 {0xffffffff, false}, 182 {0xffffffff, false},
180 }; 183 };
181 184
182 CheckedRange<uint32_t> parent_range(0x2000, 0x1000); 185 CheckedRange<uint32_t> parent_range(0x2000, 0x1000);
183 ASSERT_TRUE(parent_range.IsValid()); 186 ASSERT_TRUE(parent_range.IsValid());
184 187
185 for (size_t index = 0; index < arraysize(kTestData); ++index) { 188 for (size_t index = 0; index < arraysize(kTestData); ++index) {
186 const TestData& testcase = kTestData[index]; 189 const TestData& testcase = kTestData[index];
187 SCOPED_TRACE( 190 SCOPED_TRACE(base::StringPrintf(
188 base::StringPrintf("index %zu, value 0x%x", index, testcase.value)); 191 "index %" PRIuS ", value 0x%x", index, testcase.value));
189 192
190 EXPECT_EQ(testcase.valid, parent_range.ContainsValue(testcase.value)); 193 EXPECT_EQ(testcase.valid, parent_range.ContainsValue(testcase.value));
191 } 194 }
192 } 195 }
193 196
194 TEST(CheckedRange, ContainsRange) { 197 TEST(CheckedRange, ContainsRange) {
195 const struct TestData { 198 const struct TestData {
196 uint32_t base; 199 uint32_t base;
197 uint32_t size; 200 uint32_t size;
198 bool valid; 201 bool valid;
(...skipping 26 matching lines...) Expand all
225 {0x2fff, 1, true}, 228 {0x2fff, 1, true},
226 {0x3000, 1, false}, 229 {0x3000, 1, false},
227 {0x3001, 1, false}, 230 {0x3001, 1, false},
228 }; 231 };
229 232
230 CheckedRange<uint32_t> parent_range(0x2000, 0x1000); 233 CheckedRange<uint32_t> parent_range(0x2000, 0x1000);
231 ASSERT_TRUE(parent_range.IsValid()); 234 ASSERT_TRUE(parent_range.IsValid());
232 235
233 for (size_t index = 0; index < arraysize(kTestData); ++index) { 236 for (size_t index = 0; index < arraysize(kTestData); ++index) {
234 const TestData& testcase = kTestData[index]; 237 const TestData& testcase = kTestData[index];
235 SCOPED_TRACE(base::StringPrintf("index %zu, base 0x%x, size 0x%x", 238 SCOPED_TRACE(base::StringPrintf("index %" PRIuS ", base 0x%x, size 0x%x",
236 index, 239 index,
237 testcase.base, 240 testcase.base,
238 testcase.size)); 241 testcase.size));
239 242
240 CheckedRange<uint32_t> child_range(testcase.base, testcase.size); 243 CheckedRange<uint32_t> child_range(testcase.base, testcase.size);
241 ASSERT_TRUE(child_range.IsValid()); 244 ASSERT_TRUE(child_range.IsValid());
242 EXPECT_EQ(testcase.valid, parent_range.ContainsRange(child_range)); 245 EXPECT_EQ(testcase.valid, parent_range.ContainsRange(child_range));
243 } 246 }
244 } 247 }
245 248
246 } // namespace 249 } // namespace
247 } // namespace test 250 } // namespace test
248 } // namespace crashpad 251 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/misc/uuid_test.cc ('k') | util/stdlib/strlcpy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698